> On Jan 5, 2016, at 7:11 PM, Joshua M. Clulow <[email protected]> wrote: > > On 5 January 2016 at 15:29, Rob Seastrom <[email protected]> wrote: >> "Because reasons" (as the kids say these days) [1], I find myself in a >> situation where I want to extract /etc/passwd lines including the hashes, so >> as to be able to automatically install them in a regenerated VM later. >> >> Basically, what I want to do is pwconv(1), only backwards. >> >> Before I take the time to write this myself, has anyone else got a pointer >> to something that does this? > > You could try something like: > > sort /etc/passwd > passwd.in > sort /etc/shadow > shadow.in > join -t : -j 1 -o 0,2.2,1.3,1.4,1.5,1.6,1.7 \ > passwd.in shadow.in > merged > > > This does not preserve the subsequent fields of shadow(4), though. I > would be inclined to just keep a copy of the interesting lines from > "passwd" and "shadow" in separate files.
Yeah, that's along the lines of what I'd be doing, likely in awk since I'm strange that way. Your point about the other fields in /etc/shadow is well taken, but in practice on these particular systems the only one that ever gets populated is lastchg (and I may not care about that one). If I were to just keep the interesting lines from both files and append them to the existing ones on a fresh VM, that should work right? Does anything get cached in the layer that looks at nsswitch.conf or should I just be able to append and keep on trucking? I suppose I could go digging in the source code, but that sounds both time consuming and error-prone... I've been exposed to just enough flavors of unix to be paranoid about this sort of thing. Thanks, -r ------------------------------------------- smartos-discuss Archives: https://www.listbox.com/member/archive/184463/=now RSS Feed: https://www.listbox.com/member/archive/rss/184463/25769125-55cfbc00 Modify Your Subscription: https://www.listbox.com/member/?member_id=25769125&id_secret=25769125-7688e9fb Powered by Listbox: http://www.listbox.com
