Link to home
Start Free TrialLog in
Avatar of bionicblakey
bionicblakey

asked on

umask and default file permission

i am working on a web project that runs on freebsd.

currently all the file that created dynamically by the internet user (they upoad file through web browser) has a default file permission of 0644.

however, i need these files to have a default extension of 0755 in order to have my perl code working.

i changed the umask from 022 to 000 for both user and root and nothing happens. every time i re-logged back in and my umask number stays the same.

i am very confuse and don't know what to do.

thanks for anybody that can give me a hand.

thanks
Avatar of ravenpl
ravenpl
Flag of Poland image

> they upoad file through web browser
I assume the www server set it's own umask, or inherits the umask from system(init process).

1. either modify the umask in the script that starts the webserver
2. I assume uploads are handledby perl/php/any other cgi. Each of them supports the chmod() function.
Avatar of bionicblakey
bionicblakey

ASKER

this ravenpl.

the server is a freebsd.

1. can you tell me where is the webserver script?
2. i can't use chmod because the default permission (0644) does not allow me to change the file permission.
i though all file upload by internet user will have user:group of http:http.  but now it somehow change the permission to my username.
thus, when internet user upload a file and perl script can't change the file permission.
> the server is a freebsd.
why then linux TA?

1. no, but I assume somwhere in the /etc (/etc/rc.d)
2. untrue. for to be able to do chmod You only have to be owner of the file - no matter what permissions it already has set. This applies to all unix flavour OSes.

again, how You handle the file uploads? It has to be some perl(php) script, and the perm changing should be done from that script (while uploading).

> i though all file upload by internet user will have user:group of http:http
propably apache's suexec (or maybe suidperl or suphp or other) is in action.
> 2. untrue. ...
untrue, at least partially.
To use chmod on a file on NFS being owner of a file is not suficient.

Are these files on NFS?check with
  cd /path/to/files/ && df .
> To use chmod on a file on NFS being owner of a file is not suficient.
Is it? What are the other requirements?
I know root user is squashed by default. I know any other may be suashed as well, but it's not the default.
no, it's not default (at least I don't know where), but the mount options count
i am sorry.  i thought freebsd is a part of linux.  and i didn't realize there is freebsd section.

the file is upload by perl script.  however, chmod by the perl script does not work because the file permission.
thus, i like to set the default umask to have file permission to 755.

thanks
the umask is inherited by perl from the calling process, your web server here
If you're using mod_perl, then you have to set the proper umask while starting your web server (which will be unsecure if there're other CGIs too).
If you use perl as CGI, then you have to configure your web server to set the proper umask for the user used to execute the CGI (in apache this is done using the suExec directive)
Also You may try changing the umask value in the perl itself(at the script starting) - it's not like restricted function
umask(0022);
but in fact, it will not affect the uploaded files, as the file was created by the server process itself(CGI is only presented with filename).
my question is there anyway that i can do to have all files default w/ execute permission??

i think i have the umask part working, however even though my umask is 0000, it only gives me 0666 instead of 0777.

thanks guys for the help.
It's normal, that execution bit is not set or files, and set for dirs. Unfortunatelly it has nothing to do with umask value.
So I guess chmod() have to e used ayway.
i can't use chmod.

is there anyway i can turn on the default execute permission.
thus, when a new file is created by the interent user, it can have execute permission w/o using chmod.

thanks
SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> is there anyway i can turn on the default execute permission.
patching/hacking the kernel or glibc ?
> is there anyway i can turn on the default execute permission.
can I ask why ?
chmod will not work.

the whole reason why i post here because my chmod does not work on my script and i believe that's because ownership problem.  i have my perl script that allow user upload file from internet.  by default, once it is upload, the file belongs to UserA and group UserA where UserA is my login name.  currently, it is default at 0644 permission.  once the file is upload, my perl script also does a chmod function to change all permission to 0777.  however, my perl script does not work now because of the permission problem.

by the way, the perl script used to work.  all files that were created used to be 0755 and my perl script was able to change all files to 0777.  however, last month, some people did something on the server and all the files created does not the have the default execute permission and my perl script does not work any more.  

thus, i am looking for a way to have the default execute permission turn on again.

thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial