Operating System - HP-UX
1833873 Members
2953 Online
110063 Solutions
New Discussion

Re: Snapshot of file permissions (script)

 
SOLVED
Go to solution
Daniel Malcor
Occasional Advisor

Snapshot of file permissions (script)

I would like to generate a script to capture the current state of file ownership and permissions in a manner that I could restore the permissions in the event of a problem with a -R update. I think I can get 95% of the states, but there are some that cannot be reaserted in octal. I have found some clever things on the net, but nothing that would take and ls -l listing and turn it into chmod symbolic notation. Anyone done this before?

Thanks,

:-Dan
Did you check the Logs?
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Snapshot of file permissions (script)

Actually there are no attributes that cannot be set using octal representation -- including sticky, setuid, and setgid bits. The same applies for numeric user/group ID's. I'd much rather have them than those mamby-pamby symbolic representations. Real UNIX guys always use the octal.


The attached Perl script will list filename, low-order 12-bits of mode, file type, uid, and gid for each argument supplied.

The exception to this rule is changing the mode of a symbolic link. The only way to chmod a symbolic link is via the undocumented lchmod() system call. If you search the Forums for lchmod, you should be able to find a small C program to do that.

If it ain't broke, I can fix that.