Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm trying to figure out how to get default permissions setup for a non shell account.
I've tried umask but it only seems to apply to my main account (shell?) and I would like to apply it to an ftp account I created. I installed and configured vsftp and played in the config file (chown_uploads=NO
chown_username=ftp-user) are not commented and this assignes the right group and user but the files have the wrong permissions for a group project -rw-r--r-- I need the members of my group to be able to also edit the files -rwxrwxr-x (775)?
I tried changing the folder options to -rwxrwsr-x but again this seems to apply to my account and not the ftp-user account.
Then I read this thread which seems to contain a solution to my answer but I get syntax errors when I try this :
Quote:
Originally Posted by nikaudio
if [ $UID -eq 502 ]; then
umask 002
fi
# id glassd
uid=502(glassd) gid=502(glassd)
Is there a way to set up umask to 0002 for nologin account ?
Slawomir
My syntax error in shell:
Code:
bash: /home/myUserAccount/.bashrc: line 17: syntax error near unexpected token `('
bash: /home/myUserAccount/.bashrc: line 17: `uid=503(ftp-user) gid=501(www-group)'
What is the language or scripting language used in bash files so I can go and read on syntax?
Is this the appropirate approche to my problem? I tried assigning default permissions for the folder with chmod -R 775
Read and tried to understand on file permissions in Linux
Read and tried to understand users and groups
umask / chmod / chown but these don't work, I have to chown and chmod everytime a user uploads files for a website!
Ok none of the things I tried seem to work so I went back and looked at the vsftpd.conf file and Googled for help on this file. Turns out there's an option in configuration that was not set correctly, no matter what I did in the OS the config file was overridding my commands!:
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=002
Now I just have to understand the default values and how to set my umask in the ftp server to get my values to -rwxrwxr-x...
The FTP server software determines the file permissions of uploaded files. The umask value is available to such applications, and by default will be used when creating new files, but security-aware applications manage this themselves.
Use vsftpd's constructs for setting upload file permissions.
The default system setting are too restrictive and applying a umask doesn't help. umask doesn't help from system or from vsftpd.conf because the defaults are all locked (default file values are -wr-------). I would change the defaults but I don't know where to do this or how. Even if I knew it wouldn't be a good idea security wise to assign low restrictions to ftp user accounts.
I want to be able to overide the system settings for the public_html folders ONLY. The ftp-user account is not a shell account. I've tried all the settings in the vsftp.conf file, read the user guide but to no avail. All ftp uploads are inaccessible and chmod after every client upload is not a solution.
Last edited by Yam-Joyous; 08-18-2010 at 01:43 PM.
Exactly, it is not a good idea to reduce restrictions. It creates real DoS security issues.
Ignore umask - it is not relevant here.
All that you want can be accomplished with vsftpd's configuration parameters. How you accomplish this depends on what you want to allow of your users whose public_html directories will be uploaded. Do these users have shell accounts? Are they to be trusted?
If you want users to be able to upload to their public_html folders, you probably don't want the ftp-user account. You'll want either virtual or real user accounts.
Perhaps it would be better to describe our needs completely.
There are plenty of HowTo's, etc. on how to configure vsftpd for various situations.
Most importantly, for anyone setting up an ftp server, is to learn about how each setting affects an ftp login, and security. Don't skimp here.
I got a bit done yesterday with the ACLs but I am still having trouble as my files are missing the execute bit on creation. I have the proper username and group assignments but that last x won't show. I can't figure out if I have done something else in the past that is now hindering my efforts at the ACL level. Sticky bit?
I read on another page where someone suggests -r to reset or reread the ACLs but can't figure out the sintax for that and where I should apply it.
I'm going to try removing the sticky bit and see if that helps. I removed Samba shares from /srv/www/domain/public_html
To answer questions about do I trust users? No catagorically. It's bad enough I screw things up, I'm not going to add other users into the mix!
P.S.: This whole project is to teach myself about Linux/administration/configuration but my main purpose in life is to learn to code and become a developper. But I'm the type of person who when he sits behind the wheel of a car, needs to understand how things under the hood work. What if I break down in the middle of no where and need to fix it to survive? Same thing with computers, I need to understand what is going on or I don't feel comfortable sitting behind the keyboard!
I removed the stickbit chmod -t -s
I removed the ACLs setfacl -b public_html
Now when I create a file it has these permissions:
-rw------- 1 ftp-user www-group 316 Aug 19 16:09 untitled2.php
I don't know what to try, I'll go see if I can find the howto on -r option something about rereading the acls or resetting...
It is simply not possible to create files with default execute permissions. On most systems, default directory permissions = 755; default file permissions = 644. Using the umask command, you can elevate 755 to 777 and 644 to 666; but you won't be able to elevate 666 to 777. It's a security measure and unless I'm mistaken it is actually built into the kernel so you'd have to edit and recompile the kernel source to bend it the way you like. There is reason for those restrictions, though, so you'd better not.
It is simply not possible to create files with default execute permissions. On most systems, default directory permissions = 755; default file permissions = 644. Using the umask command, you can elevate 755 to 777 and 644 to 666; but you won't be able to elevate 666 to 777. It's a security measure and unless I'm mistaken it is actually built into the kernel so you'd have to edit and recompile the kernel source to bend it the way you like. There is reason for those restrictions, though, so you'd better not.
I disagree, it depends on the limitations of the software/server.
proftpd can do this using their umask directive located within proftpd.conf. I have a software server setup with this very directive in mind on a corporate intranet.
You just have to read the docs for vsftp and see if they provide a like option.
I agree with Mr. C.: "Don't skimp here."
It is always a good idea, when dealing with user uploads, to umask them as 027. That way the permissions are private away from the public by default and the user can change them later if they wish.
Well, I guess I may indeed have been skimping. Then again, I'm not sure what to make of that C code. That would illustrate the case of a user explicitly/manually granting execute permission, which is different from execute permission assigned as a default at file creation time. I never said it can't be done that way.
Just open a terminal and enter:
umask 000
create a directory and it will be 777
enter that directory and create a file: it will be 666, in spite of the 000 mask.
I may well be mistaken about it being a kernel feature. Then again, I wouldn't know where it is set (it may just as well be compiled into the shell, though, I don't know). I know that grepping /etc for any umask that specifically governs file creation didn't produce anything useful.
The kernel allows files to be created with whatever permissions are requested by the program creating the file. The code was a demonstration of this.
By *default*, files and directories are created with full permissions (i.e. 666 and 777) minus the permissions negated with the umask value. This occurs when the program creating the file / directory does not set an explicit mode in an open(2) or creat(2) system call.
Generally it does not make sense to create files with execute permissions, so programs don't do this. But there is no reason why they can't (again, see above program). A compiler, for example, creates an executable a.out file when it is completed. Whether this is done by creating an executable a.out file, or by simply creating a file, and then setting explicit permissions via chmod(2) is left as an exercise for curious readers (hint: man truss or man strace).
Well written programs always set explicit file modes when they create files, so as not to create unexpected results.
The process' (vsftpd) umask setting, as I mentioned, is *ignored* by vsftpd, because vsftpd *always* controls file permissions using the settings from the vsftpd.conf file.. It does not leave such settings to external control such as the umask shell built-in (which calls umask(2) to set the process' umask value). This would require the system admin to configure various shell startup configuration files, and is not as flexible. Again, vsftpd controls its own permissions.
umask is simple inherited by a process, but a parent process cannot (repeat, cannot!) force a child to retain or even use this value.
Best to show your vsftpd.conf (and other vsftpd related) configuration files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.