in reply to Re: Does this user exist?
in thread Does this user exist?

Please,

I did not ask of your opinions on the security of this script, but merely help on a certain aspect of it. Yes i am running taint, yes i have regexps on user input - and NO this is not a live web system.

If my server gets hacked or trashed, its my fault i know.

ALL of my users have directories in /home, can someone please shed some light on how to compare the data in $username with what is in the /home directory, and return an error if the folder/username already exists.

Replies are listed 'Best First'.
Re^3: Does this user exist?
by diotalevi (Canon) on Jan 01, 2003 at 17:53 UTC

    Oh well that's easy: carp "Directory found" if -e "/home/$username";. The thing is, if you couldn't code that then I don't think you're competent to code the rest of the sytem.


    Fun Fun Fun in the Fluffy Chair

      I wouldn't make such a bold assertion. A user's home directory is not necessarily in /home, and a user does not necessarily have a home directory in order to be valid.

      Perhaps you should try to spend more time answering the question than making bad judgements of the OP's competence.

        I did think about writing that using a constant like use constant HOME_DIR => '/home/' but then I thought that'd be obvious. But then I don't agree with the premise of testing for user-existance by checking for directory existance in some common location.

        The overall idea of these three responses to this question is that guru-alike is required to write these sorts of things safely. If carp "Foo!" unless -e HOME_DIR . $username was even part of the question then it is quite obvious that the person posting the question is not up to the task (yet).

        It would likely be a good exercise for Anonymous Monk to write the code and request a review. At least that will earn the programmer some experience and will prepare them for doing the task for real, later. A review alone isn't sufficient to vet some code for security but it's a good start. In addition, full understanding of the execution environment is required and that just isn't possible (or at least highly unlikely) here.

        It occurs to me that Webmin might be a better fit for the overall question. While Webmin itself is not secure at least it does the same job with some (perhap?) less obvious problems.


        Fun Fun Fun in the Fluffy Chair