[Pkg-shadow-devel] useradd durability improvement

Serge Hallyn serge.hallyn at ubuntu.com
Wed Mar 9 08:17:31 UTC 2016


Quoting Cat Zimmermann (cat.zimmermann at crowdstrike.com):
> Hello Serge and others on Pkg-shadow-devel,
> 
> I believe the useradd utility is missing an fsync on the /etc directory itself to ensure durability after each rename.
> 
> Below is strace output on RHEL7 and Ubuntu 14.04.3.
> 
> Cheers,
> Cat Zimmermann
> 
> $ strace -y useradd -M fakeuser 2>&1 | grep /etc | grep "rename\|fsync”
> 
> fsync(11</etc/passwd->)                 = 0
> fsync(4</etc/passwd+>)                  = 0
> rename("/etc/passwd+", "/etc/passwd")   = 0
> fsync(4</etc/shadow->)                  = 0
> fsync(4</etc/shadow+>)                  = 0
> rename("/etc/shadow+", "/etc/shadow")   = 0
> fsync(4</etc/group->)                   = 0
> fsync(4</etc/group+>)                   = 0
> rename("/etc/group+", "/etc/group")     = 0
> fsync(4</etc/gshadow->)                 = 0
> fsync(4</etc/gshadow+>)                 = 0
> rename("/etc/gshadow+", "/etc/gshadow") = 0
> fsync(4</etc/subuid->)                  = 0
> fsync(4</etc/subuid+>)                  = 0
> rename("/etc/subuid+", "/etc/subuid")   = 0
> fsync(4</etc/subgid->)                  = 0
> fsync(4</etc/subgid+>)                  = 0
> rename("/etc/subgid+", "/etc/subgid")   = 0
> 
> $ done.

Hm, indeed the manpage suggests a fsync("/etc") would be wise.



More information about the Pkg-shadow-devel mailing list