[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: new static uid/gid needed (ups)



On 1999/08/25, Jozef Hitzinger wrote:
> On 25 Aug 1999, Ruud de Rooij wrote:
> 
> > Why does it _need_ to be static?  Is there a reason why you can't add
> > the user at installation time with adduser --system?
> 
> The ids get compiled into binaries. If there's a way how to cope with it
> with adduser --system, please tell me.

Can't you determine the uid at run time with code similar to the following?

    struct passwd * passwd_entry;
    uid_t           ups_uid;

    if (! (passwd_entry = getpwnam("ups"))) {
        fprintf(stderr, "user id `ups' does not exist\n");
        exit(EXIT_FAILURE);
    }
    ups_uid = passwd_entry->pw_uid;

It would make the program also more robust against changes in the uid 
numbering done by the system administrator.

	- Ruud de Rooij.
-- 
ruud de rooij | ruud@ruud.org | http://ruud.org



Reply to: