LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   umask and default file create permissions (https://www.linuxquestions.org/questions/linux-newbie-8/umask-and-default-file-create-permissions-60652/)

Rgamboa 05-19-2003 12:14 PM

umask and default file create permissions
 
I understand how to use umask in my .profile. It turns off default permissions. But how do I turn ON default permissions? If the default file create permissions are 0666 and I want them to be 0777, what do I have to do in my .profile? (Sorry if this is a dumb question.)

MasterC 05-19-2003 01:19 PM

set a umask of 7000:
umask=7000

However, that's just plain a bad idea. Default permissions (and permissions in general) are there for system safety, system integrity and for personal privacy. If you set a umask of 000 (or chmod 777) on all your files then everyone can see them, alter them, delete them, write over them... Bad idea.

Cool

Rgamboa 05-19-2003 03:49 PM

Clarification
 
I'm sorry if I misled you. I only want to add permissions when FTP'ing in from the outside using one special userid. Also, I don't think that umask can turn on additional permissions; it can only specify read-write-execute permissions to be turned off. So the real question is either 1) how can I change the default file creation permissions, or 2) how can I issue a 'chmod' from another server? (Perl's FTP modules doesn't seem to have a chmod() function.)

MasterC 05-19-2003 11:17 PM

Do you have access to the server you are ftp-ing into? Which ftp server are they using? In proftpd you can specify your umask desires, but you can also set specific directory calls:
Code:

<Directory /*>
  <Limit READ>
  AllowAll
  </Limit
</Directory>

Other options are the global umasks, but that would set it for everyone ftp'ing in. As for umask turning on/off permissions I don't think it's quite like that. It's not on or off, it's setting the permissions:
000 = 777
111 = 666
And so on. So a umask of 000 gives full permissions, it doesn't turn something on or off AFAIK.

So... what kind of options do you have? Well, what server is the FTP server? Do you have admin control over it? Are you ftp'ing in when you might wanna consider ssh'ing?

:)

Please, just try to tell us a bit more about your setup, it'll help to get a bit more of a response ;)

Cool

Rgamboa 05-20-2003 10:03 AM

Thanks!
 
Thanks for not giving up on me. We own both servers and, yes, I have superuser access to each. (WHEE!) We use ssh to login and sftp for file transfer. We want server1 to ftp to server2 using username 'cronman'. We want files created to have more liberal permissions than we're getting. We tried setting umask in cronman's .profile but it can only turn permissions off, not on. I just ran a test with umask to prove this:

% echo >temp.fil
% ls -adl temp*
-rw-rw-rw- 1 dhannott staff 0 May 20 10:55 temp.fil
% umask
0
% umask 0007
% echo >temp2.fil
% ls -adl temp*
-rw-rw-rw- 1 dhannott staff 0 May 20 10:55 temp.fil
-rw-rw---- 1 dhannott staff 0 May 20 10:55 temp2.fil

As you can see, umask turned off global permissions, but failed to turn on any owner or group permissions.

MasterC 05-20-2003 11:03 AM

Ok, so looking over the docs at proftpd (I'm still assuming that's the FTP server you are using :) ) it looks like you could set it up on a per directory basis on the server side. If this is a public folder you probably don't want to do this. If this is public, you could setup a private directory where your user ftp's into, make it have the chmod 777/umask 000 and then have a cron setup to move the files (every 5 minutes or so) in /path/to/private to /path/to/public after chmodding them 555 or something more restrictive. Here's the directory syntax I'd try in the proftpd.conf file (make sure you are doing this outside of your <Anonymous> block):
<Directory /home/testuser/testdirectory/*>
umask 0007
<Limit READ>
AllowAll
</Limit>
<Limit WRITE>
AllowAll>
</Limit>
<Limit EXEC>
AllowAll
</Limit>
</Directory>
Then restart proftpd either by sending the HUP to your inetd pid or for standalone just restarting proftpd:
proftpd restart

Short of that working, you could setup a cron to chmod your files, but that would be taxing your system if you had it running every minute. Another option is to setup a global umask 000 and then set limits in every users profile (if that's even feasible) to restrict that.

If none of that works, post back and I'll do some more looking :)

Cool


All times are GMT -5. The time now is 07:47 PM.