[Gambas-user] Properties of the Stat class (gb) -

Hans Lehmann hans at gambas-buch.de
Tue Jun 12 12:33:12 CEST 2018


Hello,

I'm experimenting with the properties of the Stat class (gb) for another 
chapter in the Gambas book.

First, a temporary file with a random file name is created in all three 
cases.
Then the owner and the group will be changed with the instructions Chown 
and Chgrp.
Afterwards, different file rights are assigned in three cases.
Finally, the file properties are read out and displayed with a Stat 
object (FileInfo = Stat(sFilePath)) and Access(path [, mode ] ).

Source code section:

sRandomFileName = SetRandomFileName()
sFilePath = Temp(sRandomFileName)
...
Shell Subst$("touch &1; echo 'ZEILE 1\nZEILE 2' > &1", sFilePath) Wait
Chown sFilePath To User.Name
Chgrp sFilePath To sGroup

Three results (gambas program and console):

(1)
Chmod sFilePath To "rwxrw-r--"
Path = /tmp/gambas.1000/5750/f4ec9844.tmp
File-Type (Integer) = 1
File-Type = Regular file
Permissions (Symbolic notation) = rwxrw-r--
File-Modus (Numeric Notation)   = 764
Sticky-Bit set? = False
SetUID set? = False
SetGID set? = False

hans at mint-183 ~ $ stat -c "%a %A" /tmp/gambas.1000/5750/f4ec9844.tmp
764 -rwxrw-r--

------------------------------------------------------------------------

(2)
Chmod sFilePath To "rwSrwSr-T"
Path = /tmp/gambas.1000/5180/161632d2.tmp
File-Type (Integer) = 1
File-Type = Regular file
Permissions (Symbolic notation) = rwSrwSr-T
File-Modus (Numeric Notation)   = 7664
Sticky-Bit set? = True
SetUID set? = True
SetGID set? = True

hans at mint-183 ~ $ stat -c "%a %A" /tmp/gambas.1000/5180/161632d2.tmp
7664 -rwSrwSr-T

------------------------------------------------------------------------

(3)
Chmod sFilePath To "rwsrwsrwt"
Path = /tmp/gambas.1000/5829/fb60cd7b.tmp
File-Type (Integer) = 1
File-Type = Regular file
Permissions (Symbolic notation) = rw-rw-rw-
File-Modus (Numeric Notation)   = 666
Sticky-Bit set? = False
SetUID set? = False
SetGID set? = False

hans at mint-183 ~ $ stat -c "%a %A" /tmp/gambas.1000/5829/fb60cd7b.tmp
666 -rw-rw-rw-

In the first two cases, the values of the properties that were expected 
were obtained. The displayed file rights as string should have the same 
syntax as CHMOD in the documentation on 
http://gambaswiki.org/wiki/cat/mode It's not like that. Assigned rights: 
"rwsrwsrwt"; read: "rw-rw-rw-". Mistake?

The documentation contains the following information:

... if there is an s or S at the 3rd position (owner), .... then the 
SetUID.bit is always set,
... if at the 6th position (group) an s or S stands, .... then the 
SetGID.bit is always set,
... if the 9th position (Other) is t or T, ... then the sticky bit is 
always set.

In the third case, however, there are three contradictions. It is 
indicated that neither the SetUID.Bit, SetGID.Bit nor the Sticky-Bit 
have been set. Is there an error here or am I wrong with my algorithms?

The project used is attached.

Regards,

Hans

-------------- next part --------------
A non-text attachment was scrubbed...
Name: FileProperties-1.1.8.tar.gz
Type: application/gzip
Size: 13054 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180612/fba5d778/attachment.gz>


More information about the User mailing list