IPWorks SSH 2020 Node.js Edition

Questions / Feedback?

FilePermissions Property

A 32-bit integer containing the a POSIX-compatible file permission bitmask.

Syntax

 sftp.getFilePermissions([callback])
 sftp.setFilePermissions( filePermissions, [callback])

Default Value

0

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for the getFilePermissions([callback]) method is defined as:

function(err, data){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'data' is the value returned by the method.

The callback for the setFilePermissions([callback]) method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

A 32-bit integer containing the a POSIX-compatible file permission bitmask.

The bitmask should be interpreted as a decimal value of a series of octal digits. For example, an octal permission value of "100644" would be "33188" in base-10, and "40755" in octal would be "16877" in base-10.

The last three octal digits are the most significant and represent, in order, the file access capabilities of the file's owner, the owner's group and other users. Each of these octal digits is, on its own, a 3-bit bitmask with the following possible values:

1 (001)Execute
2 (010)Write
4 (100)Read

An octal permission digit of 7 would have all three values set and would mean that the file can be read, written and executed by that user class. For example, the octal permissions "100644" would have a value "6" for the owner, "4" for the group, and "4" for other users. This would be interpreted to mean that all users can read the file, no users can execute it and only the owner can write it. The permissions "40755" would mean that all users can read and execute the file, but only the owner can write it.

The previous octal digit is another bitmask with the following values:

1 (001)Sticky Bit - retain the file in memory for performance
2 (010)Set GID - sets the group ID of the process to the file's group ID upon execution (only for executable files)
4 (100)Set UID - sets the user ID of the process to the file's user ID upon execution (only for executable files)

The previous two octal digits are used together as a bitmask to determine the type of file. This bitmask has the following values:

01 (000001)Named pipe
02 (000010)Character special
04 (000100)Directory
06 (000110)Block special
10 (001000)Regular
12 (001010)Symbolic link
14 (001100)Socket

For example, the octal file permissions "100644" would indicate a regular file and octal "40755" would indicate a directory.

Please note that you will need to convert the octal permissions bitmask into its decimal representation

This property is not available at design time.

Data Type

Integer

Copyright (c) 2023 /n software inc. - All rights reserved.
IPWorks SSH 2020 Node.js Edition - Version 20.0 [Build 8501]