Commit Diff


commit - b9e02d8e201a3e81d76aed4280e900e8cd2cd4a2
commit + ea947d481662dcd3c4643733d59dffbfc32ddf44
blob - c431834a535ed93eceff7ef465bbc08c90e59e91
blob + ef75cf29e7967d8b471a6f9f09ebe872199ab5e9
--- thingsctl/thingsctl.c	
+++ thingsctl/thingsctl.c	
@@ -263,10 +263,7 @@ print_thgs(struct thg_imsg *pthgs)
 		printf("\tMax Clients:\t\tunlimited\n");
 	else
 		printf("\tMax Clients:\t\t%d\n", pthgs->max_clt);
-	if (geteuid() != 0)
-		printf("\tPassword:\t\t********\n");
-	else
-		printf("\tPassword:\t\t%s\n", pthgs->password);
+	printf("\tPassword:\t\t%s\n", pthgs->password);
 	printf("\tClient Count:\t\t%zu\n", pthgs->clt_cnt);
 	if (pthgs->tls == false)
 		return;
blob - 9351d0461c21f36a8e5c86cb68978fa23b824cb5
blob + 68a3c22218de96ddc1232215fbd9bfc1da197ccf
--- thingsd/control.c	
+++ thingsd/control.c	
@@ -198,6 +198,7 @@ control_dispatch_imsg(int fd, short event, void *bula)
 {
 	struct ctl_conn		*c;
 	struct imsg		 imsg;
+	enum thgs_list_type	 type;
 	ssize_t			 n;
 	uid_t			 euid;
 	gid_t			 egid;
@@ -236,6 +237,13 @@ control_dispatch_imsg(int fd, short event, void *bula)
 			break;
 
 		switch (imsg.hdr.type) {
+		case IMSG_THGS_LOG_VERBOSE:
+			if (euid != 0) {
+				imsg_free(&imsg);
+				control_close(fd);
+				return;
+			}
+			break;
 		default:
 			break;
 		}
@@ -245,8 +253,15 @@ control_dispatch_imsg(int fd, short event, void *bula)
 			if (IMSG_DATA_SIZE(imsg) !=
 			    sizeof(enum thgs_list_type))
 				break;
-			main_imsg_compose_thgs(imsg.hdr.type, 0,
-			    imsg.data, IMSG_DATA_SIZE(imsg));
+			memcpy(&type, imsg.data, sizeof(type));
+			if (type == THGS_LIST_THGS && euid == 0) {
+				type = THGS_LIST_THGS_ROOT;
+				main_imsg_compose_thgs(imsg.hdr.type, 0,
+				    &type, sizeof(type));
+			}
+			else
+				main_imsg_compose_thgs(imsg.hdr.type, 0,
+				    imsg.data, IMSG_DATA_SIZE(imsg));
 			break;
 		case IMSG_THGS_LOG_VERBOSE:
 			if (imsg.hdr.len != IMSG_HEADER_SIZE +
blob - e067414347e5a36eedbabe1ea44cbfef183bbdb9
blob + 3062721987a298ed7d0b6c366c88592c9a34e529
--- thingsd/things.c	
+++ thingsd/things.c	
@@ -315,9 +315,10 @@ show_list(enum thgs_list_type type, pid_t pid)
 			free(clt_imsg);
 		}
 		break;
+	case THGS_LIST_THGS_ROOT:
 	case THGS_LIST_THGS:
 		TAILQ_FOREACH(thg, &pthgsd->thgs, entry) {
-			thg_imsg = compose_thgs(thg);
+			thg_imsg = compose_thgs(thg, type);
 			thgs_imsg_compose_main(IMSG_LIST_THGS, pid, thg_imsg,
 			    sizeof(*thg_imsg));
 			free(thg_imsg);
@@ -359,9 +360,10 @@ compose_clts(struct clt *pclt)
 };
 
 struct thg_imsg *
-compose_thgs(struct thg *pthg)
+compose_thgs(struct thg *pthg, int type)
 {
 	struct thg_imsg		*comp_thg;
+	char			*blank = "********";
 
 	if ((comp_thg = calloc(1, sizeof(*comp_thg))) == NULL)
 		fatalx("no com_thg calloc");
@@ -378,8 +380,16 @@ compose_thgs(struct thg *pthg)
 		strlcpy(comp_thg->name, pthg->name, BUFF);
 	if (pthg->parity != NULL)
 		strlcpy(comp_thg->parity, pthg->parity, BUFF);
-	if (pthg->password != NULL)
-		strlcpy(comp_thg->password, pthg->password, BUFF);
+	if (pthg->password != NULL) {
+		switch (type) {
+		case THGS_LIST_THGS_ROOT:
+			strlcpy(comp_thg->password, pthg->password, BUFF);
+			break;
+		case THGS_LIST_THGS:
+			strlcpy(comp_thg->password, blank, BUFF);
+			break;
+		}
+	}
 	if (pthg->location != NULL)
 		strlcpy(comp_thg->location, pthg->location, BUFF);
 	if (pthg->udp != NULL)
blob - bdf1584b24be6c26978a240441402066122e62c8
blob + 2708644bbf923a39a05dd6b14ebd0b59dc76ad38
--- thingsd/things.h	
+++ thingsd/things.h	
@@ -26,6 +26,6 @@ void			 show_list(enum thgs_list_type, pid_t);
 int		 	 thgs_imsg_compose_main(int, pid_t, void *, uint16_t);
 struct thgsd		*pthgsd;
 struct dthgs		*pdthgs;
-struct thg_imsg		*compose_thgs(struct thg *);
+struct thg_imsg		*compose_thgs(struct thg *, int);
 struct clt_imsg		*compose_clts(struct clt *);
 struct sock_imsg	*compose_socks(struct sock *);
blob - 7fe1bf5176623be21a7cf5851a201a07a478e237
blob + 1edebe9a75099e6eeb36b99e3cdb306860d30f5f
--- thingsd/thingsd.h	
+++ thingsd/thingsd.h	
@@ -253,6 +253,7 @@ static const char * const log_procnames[] = {
 enum thgs_list_type {
 	THGS_LIST_CLTS,
 	THGS_LIST_THGS,
+	THGS_LIST_THGS_ROOT,
 	THGS_LIST_SOCKS,
 };