about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2012-01-03 21:05:35 +0100
committerAlexander Barton <alex@barton.de>2012-01-03 21:05:35 +0100
commit1bb2fbedcc975aa6e424fd201f59a178a03d45b0 (patch)
tree502315d958841ef857fda257474fd88ae0cd41a1 /src
parent3193d5477c9f70e34f7ae636e51771b8e6039138 (diff)
downloadngircd-1bb2fbedcc975aa6e424fd201f59a178a03d45b0.tar.gz
ngircd-1bb2fbedcc975aa6e424fd201f59a178a03d45b0.zip
Enhance log messages when setting user and group
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/ngircd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c
index ec2462ae..874dfa3f 100644
--- a/src/ngircd/ngircd.c
+++ b/src/ngircd/ngircd.c
@@ -658,10 +658,10 @@ NGIRCd_Init(bool NGIRCd_NoDaemon)
 
 	/* Check user ID */
 	if (Conf_UID == 0) {
+		pwd = getpwuid(0);
 		Log(LOG_INFO,
-		    "ServerUID must not be 0, using \"nobody\" instead.",
-		    Conf_UID);
-
+		    "ServerUID must not be %s(0), using \"nobody\" instead.",
+		    pwd ? pwd->pw_name : "?");
 		if (!NGIRCd_getNobodyID(&Conf_UID, &Conf_GID)) {
 			Log(LOG_WARNING,
 			    "Could not get user/group ID of user \"nobody\": %s",
@@ -674,8 +674,10 @@ NGIRCd_Init(bool NGIRCd_NoDaemon)
 	if (getgid() != Conf_GID) {
 		if (setgid(Conf_GID) != 0) {
 			real_errno = errno;
-			Log(LOG_ERR, "Can't change group ID to %u: %s",
-			    Conf_GID, strerror(errno));
+			grp = getgrgid(Conf_GID);
+			Log(LOG_ERR, "Can't change group ID to %s(%u): %s",
+			    grp ? grp->gr_name : "?", Conf_GID,
+			    strerror(errno));
 			if (real_errno != EPERM) 
 				goto out;
 		}
@@ -685,8 +687,10 @@ NGIRCd_Init(bool NGIRCd_NoDaemon)
 	if (getuid() != Conf_UID) {
 		if (setuid(Conf_UID) != 0) {
 			real_errno = errno;
-			Log(LOG_ERR, "Can't change user ID to %u: %s",
-			    Conf_UID, strerror(errno));
+			pwd = getpwuid(Conf_UID);
+			Log(LOG_ERR, "Can't change user ID to %s(%u): %s",
+			    pwd ? pwd->pw_name : "?", Conf_UID,
+			    strerror(errno));
 			if (real_errno != EPERM)
 				goto out;
 		}