PxConfig-functions and umask()

How can I create config files with world write access?

I tried:


#include <stdio.h>
#include <photon/PxProto.h>
#include <sys/types.h>
#include <sys/stat.h>


void main(void)
{
umask(0);
if(0 != PxConfigOpen( “./bla.ini”, PXCONFIG_WRITE| PXCONFIG_CREATE ) )
{
PxConfigWriteBool( “Test”, “locked”, PXCONFIG_FMT_BOOL_YES, !0 );
PxConfigClose();
}
}

but my ‘bla.ini’ always looks like this:

-rw-rw-r-- 1 kho mbs 20 Aug 30 15:55 bla.ini

Looks strange. Any ideas?

(I know, I could do a chmod() after closing …)


| / | __ ) | Karsten.Hoffmann@mbs-software.de MBS-GmbH
| |/| | _ _
\ Phone : +49-2151-7294-38 Karsten Hoffmann
| | | | |
) |__) | Fax : +49-2151-7294-50 Roemerstrasse 15
|| ||// Mobile: +49-172-3812373 D-47809 Krefeld

cmask ?

<Karsten.Hoffmann@mbs-software.de> schrieb im Newsbeitrag
news:akntl9$d7u$1@mbs-software.de

How can I create config files with world write access?

I tried:


#include <stdio.h
#include <photon/PxProto.h
#include <sys/types.h
#include <sys/stat.h


void main(void)
{
umask(0);
if(0 != PxConfigOpen( “./bla.ini”, PXCONFIG_WRITE| PXCONFIG_CREATE ) )
{
PxConfigWriteBool( “Test”, “locked”, PXCONFIG_FMT_BOOL_YES, !0 );
PxConfigClose();
}
}

but my ‘bla.ini’ always looks like this:

-rw-rw-r-- 1 kho mbs 20 Aug 30 15:55 bla.ini

Looks strange. Any ideas?

(I know, I could do a chmod() after closing …)


| / | __ ) | > Karsten.Hoffmann@mbs-software.de > MBS-GmbH
| |/| | _ _
\ Phone : +49-2151-7294-38 Karsten Hoffmann
| | | | |
) |__) | Fax : +49-2151-7294-50 Roemerstrasse 15
|| ||// Mobile: +49-172-3812373 D-47809 Krefeld

Peter Weber <pw@dolphin.de> wrote:

cmask ?

You mean the argument of the umask()-function? It’s zero
as quoted in the sample code.

BTW: if I use ‘umask(0777);’ instead, I get the access rights set
as expected:

---------- 1 kho mbs 20 Sep 02 15:05 bla.ini


[quoted just to keep the context]

Karsten.Hoffmann@mbs-software.de> > schrieb im Newsbeitrag
How can I create config files with world write access?

I tried:


#include <stdio.h
#include <photon/PxProto.h
#include <sys/types.h
#include <sys/stat.h


void main(void)
{
umask(0);
if(0 != PxConfigOpen( “./bla.ini”, PXCONFIG_WRITE| PXCONFIG_CREATE ) )
{
PxConfigWriteBool( “Test”, “locked”, PXCONFIG_FMT_BOOL_YES, !0 );
PxConfigClose();
}
}

but my ‘bla.ini’ always looks like this:

-rw-rw-r-- 1 kho mbs 20 Aug 30 15:55 bla.ini


| / | __ ) | Karsten.Hoffmann@mbs-software.de MBS-GmbH
| |/| | _ _
\ Phone : +49-2151-7294-38 Karsten Hoffmann
| | | | |
) |__) | Fax : +49-2151-7294-50 Roemerstrasse 15
|| ||// Mobile: +49-172-3812373 D-47809 Krefeld

cmask ?


You mean the argument of the umask()-function? It’s zero
as quoted in the sample code.
No I mean the CMASK of the process environment which is 02 in most cases

and clears the ‘other w-bit’. Mostly set in the .profile.
I don’t remember the name of this ENV, sorry.

BTW: if I use ‘umask(0777);’ instead, I get the access rights set
as expected:

---------- 1 kho mbs 20 Sep 02 15:05 bla.ini

Yes, umask(0) changes nothing.

[quoted just to keep the context]
Karsten.Hoffmann@mbs-software.de> > schrieb im Newsbeitrag
How can I create config files with world write access?

I tried:


#include <stdio.h
#include <photon/PxProto.h
#include <sys/types.h
#include <sys/stat.h


void main(void)
{
umask(0);
if(0 != PxConfigOpen( “./bla.ini”, PXCONFIG_WRITE|
PXCONFIG_CREATE ) )
{
PxConfigWriteBool( “Test”, “locked”, PXCONFIG_FMT_BOOL_YES, !0 );
PxConfigClose();
}
}

but my ‘bla.ini’ always looks like this:

-rw-rw-r-- 1 kho mbs 20 Aug 30 15:55 bla.ini


\


| / | __ ) | > Karsten.Hoffmann@mbs-software.de > MBS-GmbH
| |/| | _ _
\ Phone : +49-2151-7294-38 Karsten Hoffmann
| | | | |
) |__) | Fax : +49-2151-7294-50 Roemerstrasse 15
|| ||// Mobile: +49-172-3812373 D-47809 Krefeld

Peter Weber <pw@dolphin.de> wrote:

No I mean the CMASK of the process environment which is 02 in most cases
and clears the ‘other w-bit’. Mostly set in the .profile.
I don’t remember the name of this ENV, sorry.

Thanks for the hint!

I indeed found a ‘umask 2’ in the default profile ‘/etc/profile’, but
no environment variable, that had something to do with masking any
permission bits.

I also changed the default in /etc/profile to 0, but no change.

Perhaps someone of QSSL could give a comment on this :slight_smile:


| / | __ ) | Karsten.Hoffmann@mbs-software.de MBS-GmbH
| |/| | _ _
\ Phone : +49-2151-7294-38 Karsten Hoffmann
| | | | |
) |__) | Fax : +49-2151-7294-50 Roemerstrasse 15
|| ||// Mobile: +49-172-3812373 D-47809 Krefeld