From 8e508dfb4b1bf139f7e8cf507bb8cef874c5f471 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Fri, 6 Jun 2008 15:47:10 +0000 Subject: add uid and gid configuration keywords that set the user id and group id of the running nslcd process git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@745 ef36b2f9-881f-0410-afb5-c4e39611909c --- nslcd/nslcd.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'nslcd/nslcd.c') diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c index 74f76cd..22f07b2 100644 --- a/nslcd/nslcd.c +++ b/nslcd/nslcd.c @@ -510,8 +510,6 @@ static void *worker(void UNUSED(*arg)) /* the main program... */ int main(int argc,char *argv[]) { - gid_t mygid=(gid_t)-1; - uid_t myuid=(uid_t)-1; int i; /* parse the command line */ parse_cmdline(argc,argv); @@ -562,24 +560,24 @@ int main(int argc,char *argv[]) log_log(LOG_DEBUG,"setgroups() not available"); #endif /* not HAVE_SETGROUPS */ /* change to nslcd gid */ - if (mygid!=((gid_t)-1)) + if (nslcd_cfg->ldc_gid!=NOGID) { - if (setgid(mygid)!=0) + if (setgid(nslcd_cfg->ldc_gid)!=0) { - log_log(LOG_ERR,"cannot setgid(%d): %s",(int)mygid,strerror(errno)); + log_log(LOG_ERR,"cannot setgid(%d): %s",(int)nslcd_cfg->ldc_gid,strerror(errno)); exit(EXIT_FAILURE); } - log_log(LOG_DEBUG,"setgid(%d) done",(int)mygid); + log_log(LOG_DEBUG,"setgid(%d) done",(int)nslcd_cfg->ldc_gid); } /* change to nslcd uid */ - if (myuid!=((uid_t)-1)) + if (nslcd_cfg->ldc_uid!=NOUID) { - if (setuid(myuid)!=0) + if (setuid(nslcd_cfg->ldc_uid)!=0) { - log_log(LOG_ERR,"cannot setuid(%d): %s",(int)myuid,strerror(errno)); + log_log(LOG_ERR,"cannot setuid(%d): %s",(int)nslcd_cfg->ldc_uid,strerror(errno)); exit(EXIT_FAILURE); } - log_log(LOG_DEBUG,"setuid(%d) done",(int)myuid); + log_log(LOG_DEBUG,"setuid(%d) done",(int)nslcd_cfg->ldc_uid); } /* install signalhandlers for some signals */ install_sighandler(SIGHUP, sigexit_handler); -- cgit v1.2.3