[Pkg-shadow-devel] Newuidmap works with usernames instead of uids

Serge Hallyn serge.hallyn at ubuntu.com
Fri Sep 5 17:15:20 UTC 2014


Quoting Nicolas François (nicolas.francois at centraliens.net):
> Hi Bostjan,
> 
> On Fri, Sep 05, 2014 at 01:13:35AM +0200, bostjan at a2o.si wrote:
> > I forgot to push it earlier, pardon, here it is:
> > 
> > New, updated commit is here (cherry-picked the old commit and --amend -ed
> > it with your updates, to provide a clean one for you):
> > https://github.com/bostjan/shadow/commit/63f1cff362d349615e5fa4da9afb6739b6273887
> > 
> > I created new branch for this one, for you to merge one single commig:
> > https://github.com/bostjan/shadow/commits/feature/subuidgid-numeric-v2
> 
> My 2c:
> Do you need to include <grp.h>?
> 
> You could avoid the getpwnam_r call (and malloc, sysconf) by calling
> getpwnam.

Oh, yeah.  Since we're not exporting a library we don't need to worry
about thread safety do we?  So that would be fine.

> You just need to store owner_pwd.pw_uid before you enter the
> loop.
> This would also avoid the call to exit(), which IMO should be avoided in
> commonio.c (better return an error code and let the applications deal with
> the error - this can let them release a lock for example).
> 
> 
> I'm not sure regarding the guarantees you have on the size of pw_uid.
> I would recommend:
> 	sprintf(owner_uid_string, "%lu", (unsigned long int)owner_pwd.pw_uid);
> 
> This is rather cosmetic, but 
> 			if (!range_owner_pwd) {
> could be changed to:
> 			if (NULL == range_owner_pwd) {
> 
> Kind Regards,
> -- 
> Nekral



More information about the Pkg-shadow-devel mailing list