FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Coding/Development
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 05-09-2000, 02:18 PM   Postid: 20187
Axel
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: May 2000
Posts: 2
Setting file attributes on create in C program

Hello

I've wrote a simple CGI script in C.

The problem is upon file creation - create() - the system
does not automaticly sets the file attributes so
that owner can read/write/execute the file.

Well I can change the attributes using the fchmod()
but it is not good for me because the file is created only once a day and they the script writes to the file.
So I could use fchmod() all the time but this is unnessesary
overhead.

So I need that newly created file automagically receives
owner read/write/execute attributes.

Can somebody help me?

Thanks,

P.S. I create file in cgi-bin directory.
P.P.S. I am not a visitor but a Futurequest.net member
P.P.P.S. Execuse my English
------------------
Axel<!-- NO_AUTO_LINK -->
[This message has been edited by Axel (edited 05-09-00@2:23 pm)]
Axel is offline   Reply With Quote
Old 05-09-2000, 06:00 PM   Postid: 20188
 Terra
CTO FutureQuest, Inc.
 
Terra's Avatar
 
Join Date: Jun 1998
Location: Z'ha'dum
Posts: 7,678
Huh???

Then you are not reading the docs for open() and/or create() completely...

>>>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
int creat(const char *pathname, mode_t mode);

mode specifies the permissions to use if a new file is created. It is modified by the process's umask in the usual way: the permissions of the created file are (mode &amp; ~umask).

The following symbolic constants are provided for mode:

S_IRWXU
00700 user (file owner) has read, write and execute permission
S_IRUSR (S_IREAD)
00400 user has read permission
S_IWUSR (S_IWRITE)
00200 user has write permission
S_IXUSR (S_IEXEC)
00100 user has execute permission
S_IRWXG
00070 group has read, write and execute permission
S_IRGRP
00040 group has read permission
S_IWGRP
00020 group has write permission
S_IXGRP
00010 group has execute permission
S_IRWXO
00007 others have read, write and execute permission
S_IROTH
00004 others have read permission
S_IWOTH
00002 others have write permisson
S_IXOTH
00001 others have execute permission
mode should always be specified when O_CREAT is in the flags, and is ignored otherwise.

--
Terra
--If it were a snake, then ...--
FutureQuest
Terra is offline   Reply With Quote
Old 05-10-2000, 02:45 AM   Postid: 20189
Axel
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: May 2000
Posts: 2
Thank you very much.

I was using the old Unix programming manual
and there was only one function - int open(const char *pathname, int flags); in it.

Thanks again!!!
Axel is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 07:20 AM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.