[PATCH] start-stop-daemon: make --exec follow symlinks.
Joakim Tjernlund
Joakim.Tjernlund at transmode.se
Sat Apr 19 10:15:12 UTC 2008
> -----Original Message-----
> From: Denys Vlasenko [mailto:vda.linux at googlemail.com]
> Sent: den 19 april 2008 04:45
> To: busybox at busybox.net; joakim.tjernlund at transmode.se
> Subject: Re: [PATCH] start-stop-daemon: make --exec follow symlinks.
>
>
> > static int pid_is_exec(pid_t pid, const char *name)
> > {
> > char buf[sizeof("/proc//exe") + sizeof(int)*3];
> > - char *execbuf;
> > - int n;
> > + struct stat st;
> >
> > sprintf(buf, "/proc/%u/exe", pid);
> > - n = strlen(name) + 1;
> > - execbuf = xzalloc(n + 1);
> > - readlink(buf, execbuf, n);
> > -
> > - /* if readlink fails, execbuf still contains "" */
> > - n = strcmp(execbuf, name);
> > - if (ENABLE_FEATURE_CLEAN_UP)
> > - free(execbuf);
> > - return !n; /* nonzero (true) if execbuf == name */
> > + if (stat(buf, &st) <0)
> > + return 0;
> > + if (st.st_dev == execstat.st_dev &&
> > + st.st_ino == execstat.st_ino)
> > + return 1;
> > + return 0;
> > }
>
> "name" is unused now. Don't introduce new warnings.
yes, small mistake. I can fix that and commit it if you don't mind?
Jocke
More information about the busybox
mailing list