Dougy Mak's Blog

MY BLOG!

Archive for December, 2011

setuid/sgid

How Unix works is, when a user creates a file, the file’s group is the user’s, which means other users could not edit it. So my developers and I always had this problem, and I always had to use “chown -R www-data:www-data . ” to change all the groups of the files in the current directory, but there’s a better way. You can set up setuid.

$ chgrp ftpusers /path/to/the/ftp/directory
$ chmod g+s $_

More information: http://www.cyberciti.biz/faq/unix-bsd-linux-setuid-file/

No comments

Unix $_

$_ is a variable that holds the last argument in the last command. For example,

$ chgrp ftpusers /path/
$ chmod g+s $_

$_ would equal the path. You can also echo $_ and experiment around.

No comments

Getting control over authentication results

So, to get control over the authentication results for various errors such as no such username, wrong password, etc..  You can use this:

$result = $this->_auth->authenticate($adapter);
switch ($result->getCode()) {
case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
/** do stuff for nonexistent identity **/
break;
case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
/** do stuff for invalid credential **/
break;
case Zend_Auth_Result::SUCCESS:
/** do stuff for successful authentication **/
break;
default:
/** do stuff for other failure **/
break;
}

$result = $this->_auth->authenticate($adapter);

switch ($result->getCode()) {

case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:

/** do stuff for nonexistent identity **/

break;

case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:

/** do stuff for invalid credential **/

break;

case Zend_Auth_Result::SUCCESS:

/** do stuff for successful authentication **/

break;

default:

/** do stuff for other failure **/

break;

}

http://framework.zend.com/manual/en/zend.auth.introduction.html#zend.auth.introduction.results

No comments