in reply to setting file permissions through sftp

Unix permissions are most easily read when expressed in octal. The basic permissions consist of one octal digit (3 bits) for owner, group and other. The bits in each octal digit stand for: read, write and execute. So a unix file permission of 0321 (leading 0 stands for octal) would read: Here's a page with a fuller presentation and a multitude of tables to help you decode them. It also explains the set user id, set group id and stick-bit permissions.

In your example, the 0777 means that everyone (user, group and other) has all (read, write and execute) permissions. Note, however, that the file permissions will be modified by the current umask when the file is created.

Replies are listed 'Best First'.
Re^2: setting file permissions through sftp
by gman (Friar) on Feb 18, 2008 at 17:23 UTC
    I am still not understanding the relationship between what Net::SFTP::Attributes ( 'perm' => 33092, ) and unix style file permissions? Am I missing something obvious?

      You have to convert the value to octal representation, e.g.

      my $perm = 33092; printf "%o\n", $perm & 07777; # prints 504

      Also, to set the permissions, you probably want $attrs->perm( 0777 ), not $attrs->perm( [ '0777' ] ). The square brackets in the docs mean optional, i.e. you'd specify nothing to retrieve the value (combined 'setter' and 'getter' method...).

      Update: forgot to mention the '& 07777' above masks off the four octal groups of interest here, i.e. three times rwx (for user/group/other), plus the SUID/SGID/sticky octal group (the latter is the first (leftmost) one).

        Thank you! I would say that falls under the obvious :)

        And especially thanks for the update on the '& 07777' explanation.

        Thanks, Cory