Other Real-World Issues
There are some other issues that are likely to come up in the Real World. For the sake of brevity we wimp out, and instead of writing code, we simply discuss them here.
First, and most obvious, is that the /etc/group file is also likely to need
merging. With this file, it's necessary to:
Make sure that all the groups from each individual system exist in the merged
/etc/groupfile, and with the same unique GID. This is completely analogous to the username/UID issue we just solved, only the format of the file is different.Do a logical merge of users in the same group on the different systems. For example:
floppy:x:5:tolstoy,camus In u1 /etc/group floppy:x:5:george,betsy In u2 /etc/group
When the files are merged, the entry for group
floppyneeds to be:
floppy:x:5:tolstoy,camus,george,betsy Order of users doesn't matterThe GID of all files must be brought into sync with the new, merged
/etc/groupfile, just as was done with the UID. If you're clever, it's possible to generate thefind...| xargs chown... command to include the UID and GID so that they need to be run only once. This saves machine processing time at the expense of additional programming time.
Second, any large system that has been in use for some time will
have files with UID or GID values that no longer (or never did) exist in
/etc/passwd and /etc/group. It is possible to find such files
with:
find / '(' -nouser -o -nogroup ')' -lsThis produces a list of files in an output format similar to that of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access