english/libraries/joomla/application/cli/daemon.php
/**
	 * Method to change the identity of the daemon process and resources.
	 *
	 * @return  boolean  True if identity successfully changed
	 *
	 * @since   11.1
	 * @see     posix_setuid()
	 */
Method to change the identity of the daemon process and resources.
@return  boolean  True if identity successfully changed


Method to change the identity of the daemon process and resources . @return boolean True if identity successfully changed
protected function changeIdentity()
	{
		$uid = (int) $this->config->get('application_uid', 0);
		$gid = (int) $this->config->get('application_gid', 0);
		$file = $this->config->get('application_pid_file');
		if ($uid && (fileowner($file) != $uid) && (!@ chown($file, $uid))) {
			JLog::add('Unable to change user ownership of the proccess id file.', JLog::ERROR);
			return false;
		}
		if ($gid && (filegroup($file) != $gid) && (!@ chgrp($file, $gid))) {
			JLog::add('Unable to change group ownership of the proccess id file.', JLog::ERROR);
			return false;
		}
		if ($uid && ($info = posix_getpwuid($uid)) && is_dir($info['dir'])) {
			system('export HOME="'.$info['dir'].'"');
		}
		if ($uid && (posix_getuid($file) != $uid) && (!@ posix_setuid($uid))) {
			JLog::add('Unable to change user ownership of the proccess.', JLog::ERROR);
			return false;
		}
		if ($gid && (posix_getgid($file) != $gid) && (!@ posix_setgid($gid))) {
			JLog::add('Unable to change group ownership of the proccess.', JLog::ERROR);
			return false;
		}
		$user  = posix_getpwuid($uid);
		$group = posix_getgrgid($gid);
		JLog::add('Changed daemon identity to '.$user['name'].':'.$group['name'], JLog::INFO);
		return true;
	}
protected function changeIdentity ( ) { $ uid = ( int ) $ this -> config -> get ( 'application_uid' , 0 ) ; $ gid = ( int ) $ this -> config -> get ( 'application_gid' , 0 ) ; $ file = $ this -> config -> get ( 'application_pid_file' ) ; if ( $ uid && ( fileowner ( $ file ) != $ uid ) && ( ! @ chown ( $ file , $ uid ) ) ) { JLog :: add ( 'Unable to change user ownership of the proccess id file.' , JLog :: ERROR ) ; return false ; } if ( $ gid && ( filegroup ( $ file ) != $ gid ) && ( ! @ chgrp ( $ file , $ gid ) ) ) { JLog :: add ( 'Unable to change group ownership of the proccess id file.' , JLog :: ERROR ) ; return false ; } if ( $ uid && ( $ info = posix_getpwuid ( $ uid ) ) && is_dir ( $ info [ 'dir' ] ) ) { system ( 'export HOME="' . $ info [ 'dir' ] . '"' ) ; } if ( $ uid && ( posix_getuid ( $ file ) != $ uid ) && ( ! @ posix_setuid ( $ uid ) ) ) { JLog :: add ( 'Unable to change user ownership of the proccess.' , JLog :: ERROR ) ; return false ; } if ( $ gid && ( posix_getgid ( $ file ) != $ gid ) && ( ! @ posix_setgid ( $ gid ) ) ) { JLog :: add ( 'Unable to change group ownership of the proccess.' , JLog :: ERROR ) ; return false ; } $ user = posix_getpwuid ( $ uid ) ; $ group = posix_getgrgid ( $ gid ) ; JLog :: add ( 'Changed daemon identity to ' . $ user [ 'name' ] . ':' . $ group [ 'name' ] , JLog :: INFO ) ; return true ; }
Method to change the identity of the daemon process and resources.
Method to change the identity of the daemon process and resources .
// Get the group and user ids to set for the daemon. // Get the application process id file path. // Change the user id for the process id file if necessary. // Change the group id for the process id file if necessary. // Set the correct home directory for the process. // Change the user id for the process necessary. // Change the group id for the process necessary. // Get the user and group information based on uid and gid.