UnDocumented QNX4: usefull features.

Just discovered:

  • if you do “chmod a=rwxt /tmp”, the filesystem respects the sticky bit as
    in the other UNIXes.
    Prerequisites:
  • a /tmp should be either a plain directory on the disk or a product of
    “mount /dev/ram /tmp” for Fsys’s “-r volume” ramdisk.
  • it does not work with the /tmp obtained with “/bin/vdir -D -n /tmp”.

Tony.

PS
I’d like to start a collection of theese usefull undocumented features in
one place…

Hi Tony

If you start documenting these things, then they won’t be undocumented
anymore !

What does turning on the sticky bit on a directory do?


Tony <mts.spb.suxx@mail.ru> wrote:
T > Just discovered:
T > - if you do “chmod a=rwxt /tmp”, the filesystem respects the sticky bit as
T > in the other UNIXes.
T > Prerequisites:
T > - a /tmp should be either a plain directory on the disk or a product of
T > “mount /dev/ram /tmp” for Fsys’s “-r volume” ramdisk.
T > - it does not work with the /tmp obtained with “/bin/vdir -D -n /tmp”.

T > Tony.

T > PS
T > I’d like to start a collection of theese usefull undocumented features in
T > one place…

On Tue, 14 Dec 2004 13:09:02 -0500, Wojtek Lerch <Wojtek_L@yahoo.ca> wrote:

By “modify”, you of course mean “rename”, right? > :wink:
Erhm…

I did not try editing the other’s files in /tmp, actually.

This is how POSIX describes it:
"If a directory is writable and the mode bit S_ISVTX is set on the
directory, a process may remove or rename files within that directory
only if one or more of the following is true:

Actually, I was after the securing myself against someone else’s fooling
with my temporary files. Mainly I need it because SSH was alerting me
about excessive file permissions for /tmp when is was switching on the
ssh-agent forwardings…

I was quite surprized to discover that QNX4 supports the “sticky bit” for
directories…

Tony.

On 14 Dec 2004 16:17:00 GMT, Bill Caroselli <qtps@earthlink.net> wrote:

If you start documenting these things, then they won’t be undocumented
anymore!
H-m…

I did not think of it!
:slight_smile:

What does turning on the sticky bit on a directory do?
Usually the /tmp has read-write access for everyone, this means that

anyone has a right to erase|modify any file there even the files that do
not belong to him, including the files without the write permission at all.
The sticky bit on the directory switces on the following:

  • although one has the write permission on the directory, he is able to
    erase|modify his own files there only.

Tony.

Tony wrote:

On 14 Dec 2004 16:17:00 GMT, Bill Caroselli <> qtps@earthlink.net> > wrote:
What does turning on the sticky bit on a directory do?

Usually the /tmp has read-write access for everyone, this means that
anyone has a right to erase|modify any file there even the files that
do not belong to him, including the files without the write permission
at all.
The sticky bit on the directory switces on the following:

  • although one has the write permission on the directory, he is able to
    erase|modify his own files there only.

By “modify”, you of course mean “rename”, right? :wink:

This is how POSIX describes it:

"If a directory is writable and the mode bit S_ISVTX is set on the
directory, a process may remove or rename files within that directory
only if one or more of the following is true:

  • The effective user ID of the process is the same as that of
    the owner ID of the file.
  • The effective user ID of the process is the same as that of
    the owner ID of the directory.
  • The process has appropriate privileges."

(http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html)

Tony <mts.spb.suxx@mail.ru> wrote:

I’d like to start a collection of theese usefull undocumented features in
one place…

I’m keeping track of postings like this, in case we ever release a new
version of the QNX 4 docs. Thanks for the suggestion.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Steve Reid <stever@sreid.ott.qnx.com> wrote:
SR > Tony <mts.spb.suxx@mail.ru> wrote:

I’d like to start a collection of theese usefull undocumented features in
one place…

SR > I’m keeping track of postings like this, in case we ever release a new
SR > version of the QNX 4 docs. Thanks for the suggestion.


You can put out one last book. The “Unofficial Document of Officially
Undocumented Features”.

On Tue, 14 Dec 2004 19:14:51 +0300, Tony <mts.spb.suxx@mail.ru> wrote:

Just discovered:

  • if you do “chmod a=rwxt /tmp”, the filesystem respects the sticky bit as
    in the other UNIXes.
    Prerequisites:
  • a /tmp should be either a plain directory on the disk or a product of
    “mount /dev/ram /tmp” for Fsys’s “-r volume” ramdisk.
  • it does not work with the /tmp obtained with “/bin/vdir -D -n /tmp”.

Tony.

PS
I’d like to start a collection of theese usefull undocumented features in
one place…

A few years ago I’v sent to this forum an undocumented property of
sinit utility. For the sake of collecting undokumented features I
repeat it:
"I discovered an interesting and very usefull
property of sinit - system initialization - utility,
which I have not found in any documentation.
Normally sinit is the last call in the boot-image of a QNX4
system and it sets up the initial operating system environment.
With -r option you can define an alias prefix for the
filesystem root.
I have a diskless PC (say node 3) with a flash containing
a boot image only. I wanted to implement a primary/secondary
file-server system, so I tried the sinit call with the following
arguments:

sinit -r //1/ -r //2/ TERM=qnx

This implementation works the following way:
sinit tries to mount the filesytem of node 1 (primary file-server) for
30 seconds,if it is unsuccesfull, sinit tries to mount the filesystem
of node 2 (secondary file-server) for 30 seconds, then the first node
again till one of the filesystems is mounted succesfully. With this
implementation I could realise a typical primary/secondary
server system, and this property of sinit not only usefull but
sometimes very important. I do not know, wether it is just a hidden,
not documented feature of sinit or I can find it somewhere in QNX4
documentation."

Till now I didn’t discovered the description of this function of sinit
in the documentation, but we use it in an industrial enviroment
succesfully.


| | | | | |_ |_ || || |
|| || |_ | | | | | | |_

Jozsef Pal, Ph.D.El.Eng. Voice: +36 1 457-82-26
VEIKI Research Institute Fax: +36 1 457-82-28
Division for Control Engineering Mobil: +36 30 960-69-23
H-1251 Budapest, P.O.B. 80. Email: j.pal@veiki.hu
HUNGARY Web: http://www.veiki.hu

The QNX4 filesystem defaults to System V behaviour in assigning the file
ownerships. A newly created file gets it’s GID from the EGID of the
creating process.

Setting the SGID bit on the folder you may alter this behaviour to BSD
style - file will inherit the GID from the folder’s GID.

Tony.

PS
I could not discover what will affect folder’s SUID bit so far…

The documentation does not mention one very convenient|usefull global
variable:
extern time_t __dst_adjust; /* Seconds to add to the “timezone” to land on
UTC */

It should be used to avoid errors where the TZ may set the rule with
not-exactly-one-hour DST adjustments (I often see the plain “+3600” is
being hardcoded), which may well be NEGATIVE.

So, a code like this would always work correctly:

(void)mktime(&temporary_tm);
	if(temporary_tm.tm_isdst)
		return(-timezone + __dst_adjust);
	else
		return(-timezone);

Tony.