Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Make shadow more robust in hostile environments #4
Conversation
xnox
added some commits
Feb 27, 2015
hallyn
commented on 46a72bc
Mar 20, 2015
|
This one concerns me because it could cause change of behavior on existing (admittedly weird) systems, right? |
|
Sure, but no such system exist in a functional state. Everyone ships /etc/shadow in e.g. base-files package or similar, and it's accidental removal renders system unusable. |
|
Well, as implemented here, FORCE_SHADOW is set to false by default, and thus current behaviour is preserved. In my deployments I will be setting it to "yes". |
hallyn
commented on ee43f47
Mar 20, 2015
|
Each of the *_open files hooked here has a corresponding *_close file which calls commonio_close, which will set the new file's perms. However, it looks to me like it sets the new file's perms to be the perms on the open file. So I think this patch needs something more to set the appropriate perms on each file. Also looks like perhaps this should go into commonio_open() instead of each of the callers? Or are there cases where we dont' want this done? |
|
"However, it looks to me like it sets the new file's perms to be the perms on the open file." - I don't follow this comment. If commonio_open is called with O_CREATE option, yet said database does not exist on disk, the database is "opened" but no file is created on disk / no file pointer is created. Then at commonio_close time, the database will be created with desired default permissions. Otherwise, if database does exist, it is opened for real (fp exists) and at close time an atomic update is performed without adjustment of the file permissions. I do not want to modified the permissions, as e.g. other tools have other default permissions for these files. E.g. PAM uses 000 for shadow file. |
hallyn
replied
Apr 6, 2015
|
On Wed, Apr 01, 2015 at 04:18:35AM -0700, Dimitri John Ledkov wrote:
"However, it looks to me like it sets the new file's perms to be the perms on the open file." - I don't follow this comment. If commonio_open is called with O_CREATE option, yet said database does not exist on disk, the database is "opened" but no file is created on disk
Oh, I see. I was worried that umask is omly set at commonio_close() (well, in
fopen_set_perms) but I see that commonio_open doesn't open with O_CREATE.
So this could be fine.
|
|
Sorry, I lost track of this, I thought you were discussing it with someone else. Should we merge this at this point? |
xnox commentedMar 20, 2015
I'm patching shadow to be more robust when operating in a-typical environments, but these improvements are general enough, that I believe warrant inclusion upstream by default.
Specifically there are deployments that use nss-altfiles / nss-extrausers and thus ship alternative group/passwd/shadow/gshadow files elsewhere on the filesystem (e.g. /var/lib/passwd). In such configurations admin modifiable files /etc/passwd, /etc/group and so on may not exist. Furthermore if one is bootstrapping a new distribution from scratch, it would be nice to point shadow utilities at an empty /etc and start creating default system accounts with useradd/usermod/groupadd/etc utilities without writing initial files by hand. Hence these changes:
Overall my goal is to have fully usable system with empty /etc and with these initial patches this is achievable. At the moment I'm also working on adding full usermod support, when operating with nss-altfiles.
Please review and consider including these patches.