[Pkg-shadow-devel] [PATCH] Suppress pwconv passwd- chmod failure message
Serge Hallyn
serge.hallyn at ubuntu.com
Tue Feb 17 15:44:54 UTC 2015
Quoting Duncan Eastoe (deastoe at brocade.com):
> Hi Serge,
>
> On 02/12/2015 03:15 PM, Serge Hallyn wrote:
> > Since you only check errno if the chmod fails, I suspect the errno = 0
> > isn't needed, but it doesn't hurt either.
>
> Sure, I believe this could be removed if desired.
>
> > I'm having trouble picturing the exact way to reproduce this (tip would
> > be appreciated), but it looks ok to me.
>
> If you were to run pwconv when /etc/passwd- does not exist and when
> there is no action required by pwconv in /etc/passwd this error will
> appear. This is because the /etc/passwd- backup file will not be created
> when no action is taken on /etc/passwd and then it tries to chmod the
> non-existent file.
Yup, gotcha. Reproduced. thanks.
> Thanks,
> Duncan
>
> > Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> >
> >> Prevent chmod failure message from displaying if the failure
> >> was due to the backup file not existing.
> >>
> >> If there is no backup file present and if no changes have been
> >> made, then this error would always appear since the backup
> >> file isn't created in this situation.
> >>
> >> Signed-off-by: Duncan Eastoe <deastoe at Brocade.com>
> >> ---
> >> src/pwconv.c | 3 ++-
> >> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/src/pwconv.c b/src/pwconv.c
> >> index 515eba1..d41d5dd 100644
> >> --- a/src/pwconv.c
> >> +++ b/src/pwconv.c
> >> @@ -305,7 +305,8 @@ int main (int argc, char **argv)
> >> }
> >>
> >> /* /etc/passwd- (backup file) */
> >> - if (chmod (PASSWD_FILE "-", 0600) != 0) {
> >> + errno = 0;
> >> + if ((chmod (PASSWD_FILE "-", 0600) != 0) && (errno != ENOENT)) {
> >> fprintf (stderr,
> >> _("%s: failed to change the mode of %s to 0600\n"),
> >> Prog, PASSWD_FILE "-");
> >> --
> >> 1.7.10.4
> >>
> >>
> >> _______________________________________________
> >> Pkg-shadow-devel mailing list
> >> Pkg-shadow-devel at lists.alioth.debian.org
> >> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-shadow-devel
More information about the Pkg-shadow-devel
mailing list