Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 599185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:28:13+00:00 2026-05-13T16:28:13+00:00

i have to admit, i never really completely got the *nix filesystem permission model.

  • 0

i have to admit, i never really completely got the *nix filesystem permission model. oh, the rwxrwxrwx stuff isn’t too complicated, but i get confused easily when programs create new files and how i can handle them.

my current problem is the mixture of a (closed source) java-applet that does file uploads over ftp and php (it’s on a dedicated server and the data isn’t really critical, so i’m not all too concerned about world-writeability).

so, i have two users: ftp (1000) and apache/php (81). groups don’t match, so they’re basically “others”, if i’m correct.

an “import” directory, set to 0777 owned by ftp.

if a visitor acesses the upload page, a subdirectory named after his username is created by my script. let’s say, the visitors username is “foo”, so it’s “import/foo”, set to 0777, user 81/php.

next, the visitor uses the java applet to upload a file to this directory (test.jpg). the file’s permissions are now rw-r–r–, user ftp.

first question

the first thing i don’t understand is: i’m able to unlink that file through php.
why? the users don’t match, and the file isn’t world writeable.
is this because of the parent directories world-write permission? understandably, i can’t chown or chmod through php.

so far no problem, because as long as i can read and unlink, everythings ok.

second question

the java applet is able to upload whole directories, which is nice. if i do this, the new subdirectory import/foo/test has permissions rwxr-xr-x/ftp. the files in this directory are rw-r–r–/ftp.

now i’m out of luck. i can’t do anything with those files (besides reading, which i do successfully), no unlinking, no chmod/chowning. they just sit around and gobble up diskspace.

so, what’s the plan behind the default-permissions new files have? my guess is they have the permission set through umask, as long the creating script doesn’t chmod them to something else. am i right?

third question

what can i do about it? i mean, what would a sensible person do? can i/should i change the umask for the ftp user? (i just learned about umask yesterday). i’m not very comfortable with this, as this would affect all ftp traffic, doesn’t it? also, the server is dedicated but i’m not an admin, so my access is restricted.

i just had another idea. before starting this post i read up on the basic linux permission stuff. first, the sticky bit isn’t set anywhere in the directory chain. and then, there it was: the “set user ID bit”.
so, my current plan is to write a simple shell script with owner ftp that is other-executable with setuid. the script just transfers the file in the import directories ownership to user php.
then, after each import i just exec() that file from my php-script and process files further.

would that work? and more important: is that clean and legal? or would the sysadmin put a bounty on my head?

thx a lot!

update: i just tried to set the uid bit (4755) through winscp (through an ftp connection), but it somehow doesn’t work – it seems to “forget” only the uid bit (the other bits get set). why is that? why can’t the owner set the uid himself? is that server-specific or generally the case?

update 2:
wikipedia says it all

Due to the increased likelihood of security flaws, many operating systems ignore the setuid attribute when applied to executable shell scripts.

is it still possible for user root to set the uid-bit?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:28:14+00:00Added an answer on May 13, 2026 at 4:28 pm

    First answer

    Correct, you have permission to modify the directory so you can unlink the file. Whether that file is readable or writable to you is irrelevant.

    Second answer

    Yes you are correct that the user’s default umask will be used unless the script/applet then chmods the file permissions to something else

    Third answer

    Setting the default umask for ftp is the simplest solution, but as you say this affects all files then created by the ftp user. If that user is only used for the upload via the applet (and it should be really) then this isn’t really an issue I’d say.

    The other option is to have a cron job running that executes a script (like you suggest), chmoding/owning the files (and maybe virus scanning them etc) from the FTP upload area to somewhere on the webroot.

    You don’t state why having these files readonly to Apache is an issue (or is it the fact that the FTP root isn’t under the web root?), maybe clarifying that would help point to a sensible solution? Generally you don’t want to trust anything the user has given you unless you’ve vetted it first.

    EDIT – just seen you’re not an admin of the machine which makes things difficult.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll admit I'm a novice programmer and really the only experience I have is
I am a mac user and have never really used a pc from the
I have to admit in all my work with Java, I've never come across
I have to admit that I'm new to Java and Android. db4o seems to
I've seen this and I have to admit I'm pretty impressed: (source: blogspot.com )
This is my first post and I have to admit, I am terrible at
First, I have to admit I screwed up a little with CVS. I had
After looking around (for not terribly long I have to admit) I wonder if
I did my programming before integrating into a design and I have to admit
I admit that I have almost none experience of unittesting. I did a try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.