[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cfexecd chdir
From: |
Jason Kim |
Subject: |
Re: cfexecd chdir |
Date: |
Wed, 5 Oct 2005 14:50:49 -0400 |
User-agent: |
KMail/1.8.1 |
On Wednesday 05 October 2005 01:08, Tim Nelson wrote:
> On Sun, 2 Oct 2005, Jason Kim wrote:
> > On Mon, 3 Oct 2005, Tim Nelson wrote:
> >> On Wed, 28 Sep 2005, Jason Kim wrote:
> >>> I've noticed that cfexecd stays in the directory it was started in even
> >>> when in daemon mode. May or may not have caused a problem I was
> >>> experiencing with one of my shellcommands (the directory I started it
> >>> in was subsequently deleted). I did a bunch of stuff at the same time,
> >>> so I couldn't isolate/verify the fix, but chdir'ing to '/' is probably
> >>> a good thing anyway. Simple patch follows.
> >>
> >> Wouldn't we be better off with
> >> --------------
> >> struct passwd RootPassStruct;
> >>
> >> RootPassStruct = getpwnam("root");
> >> chdir(RootPassStruct->pw_dir);
> >> --------------
> >
> > I suppose that works too... I thought that it was common practice to cd
> > to '/' for any daemon simply because it is always guaranteed to be there.
> > As the problem I had (though I'm still not 100% sure) had to do with
> > cfexecd having a deleted directory as its cwd, I figured this would be
> > the best fix.
>
> I figure getpwnam("root") should always exist too; I know on some
> systems it's "/" and on others, "/root".
>
> Just out of interest, I ran:
> grep cd /etc/rc.d/init.d/*
>
> Of the two bits of software that actually did a "cd" in the init
> script, both did "cd /". One of them is courier-authlib (3rd-party), but
> the other is xfs (comes with my Redhat system). So maybe you're right :).
> I dunno.
>
I guess it's a decision for the author to make. A quick check of one of my
redhat servers indicates that it's more often than not...
address@hidden www]# /bin/ls -l /proc/`pgrep syslogd | head -1`/cwd
lrwxrwxrwx 1 root root 0 Oct 5 14:45 /proc/8937/cwd -> /
address@hidden www]# /bin/ls -l /proc/`pgrep sshd | head -1`/cwd
lrwxrwxrwx 1 root root 0 Oct 5 14:45 /proc/8916/cwd -> /
address@hidden www]# /bin/ls -l /proc/`pgrep xinetd | head -1`/cwd
lrwxrwxrwx 1 root root 0 Oct 5 14:45 /proc/26913/cwd -> /
Anyway, it's up to Mr. Burgess to even act on this patch, so I'll leave it up
to him...
-JayKim