Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nslcd/nslcd.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2008-06-06 17:47:10 +0200
committerArthur de Jong <arthur@arthurdejong.org>2008-06-06 17:47:10 +0200
commit8e508dfb4b1bf139f7e8cf507bb8cef874c5f471 (patch)
treeabe24b1af989fb6405009cd44c31da748793865b /nslcd/nslcd.c
parent353485a40885d0fe8284600ab8f6b99a10c5cd43 (diff)
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
Diffstat (limited to 'nslcd/nslcd.c')
-rw-r--r--nslcd/nslcd.c18
1 files changed, 8 insertions, 10 deletions
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);