2008-09-30 13:52:56 +02:00
#!/usr/bin/php -qC
2007-05-29 10:35:27 +02:00
< ? php
/**
2008-04-14 07:54:10 +02:00
* Filemanager - Command line interface
2007-05-29 10:35:27 +02:00
*
* @ link http :// www . egroupware . org
2008-03-03 08:53:43 +01:00
* @ package filemanager
2007-05-29 10:35:27 +02:00
* @ author Ralf Becker < RalfBecker - AT - outdoor - training . de >
2010-03-17 10:11:28 +01:00
* @ copyright ( c ) 2007 - 10 by Ralf Becker < RalfBecker - AT - outdoor - training . de >
2007-05-29 10:35:27 +02:00
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
* @ version $Id $
2009-05-02 14:45:06 +02:00
*
* @ todo -- domain does NOT work with -- user root_ * for domains other then the first in header . inc . php
2007-05-29 10:35:27 +02:00
*/
chdir ( dirname ( __FILE__ )); // to enable our relative pathes to work
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
error_reporting ( error_reporting () & ~ E_NOTICE );
2013-09-10 19:29:58 +02:00
if ( php_sapi_name () !== 'cli' ) // security precaution: forbit calling filemanager/cli.php as web-page
2007-05-29 10:35:27 +02:00
{
2008-01-29 08:24:16 +01:00
die ( '<h1>' . basename ( __FILE__ ) . ' must NOT be called as web-page --> exiting !!!</h1>' );
2007-05-29 10:35:27 +02:00
}
/**
2008-03-02 22:44:15 +01:00
* callback if the session - check fails , creates session from user / passwd in $GLOBALS [ 'egw_login_data' ]
2008-09-30 13:52:56 +02:00
*
2007-05-29 10:35:27 +02:00
* @ param array & $account account_info with keys 'login' , 'passwd' and optional 'passwd_type'
* @ return boolean / string true if we allow the access and account is set , a sessionid or false otherwise
*/
function user_pass_from_argv ( & $account )
{
$account = $GLOBALS [ 'egw_login_data' ];
//print_r($account);
if ( ! ( $sessionid = $GLOBALS [ 'egw' ] -> session -> create ( $account )))
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
echo " Wrong user-account or -password !!! \n \n " ;
2007-05-29 10:35:27 +02:00
usage ( '' , 1 );
}
return $sessionid ;
}
/**
* Give a usage message and exit
*
* @ param string $action = null
* @ param int $ret = 0 exit - code
*/
function usage ( $action = null , $ret = 0 )
{
2008-01-29 08:24:16 +01:00
$cmd = basename ( __FILE__ );
2009-08-27 15:07:56 +02:00
echo " Usage: \t $cmd ls [-r|--recursive|-l|--long|-i|--inode] URL [URL2 ...] \n " ;
2008-02-29 08:29:19 +01:00
echo " \t $cmd cat URL [URL2 ...] \n " ;
echo " \t $cmd cp [-r|--recursive] [-p|--perms] URL-from URL-to \n " ;
echo " \t $cmd cp [-r|--recursive] [-p|--perms] URL-from [URL-from2 ...] URL-to-directory \n " ;
echo " \t $cmd rm [-r|--recursive] URL [URL2 ...] \n " ;
echo " \t $cmd mkdir [-p|--parents] URL [URL2 ...] \n " ;
echo " \t $cmd rmdir URL [URL2 ...] \n " ;
echo " \t $cmd touch [-r|--recursive] [-d|--date time] URL [URL2 ...] \n " ;
2008-10-28 10:28:43 +01:00
echo " \t $cmd chmod [-r|--recursive] [ugoa]*[+-=][rwx]+,... URL [URL2 ...] \n " ;
2008-02-29 08:29:19 +01:00
echo " \t $cmd chown [-r|--recursive] user URL [URL2 ...] \n " ;
echo " \t $cmd chgrp [-r|--recursive] group URL [URL2 ...] \n " ;
2008-03-03 08:53:43 +01:00
echo " \t $cmd find URL [URL2 ...] [-type (d|f)][-depth][-mindepth n][-maxdepth n][-mime type[/sub]][-name pattern][-path pattern][-uid id][-user name][-nouser][-gid id][-group name][-nogroup][-size N][-cmin N][-ctime N][-mmin N][-mtime N] (N: +n --> >n, -n --> <n, n --> =n) [-limit N[,n]][-order (name|size|...)][-sort (ASC|DESC)] \n " ;
2008-02-29 08:29:19 +01:00
echo " \t $cmd mount URL [path] (without path prints out the mounts) \n " ;
2008-03-03 13:18:32 +01:00
echo " \t $cmd umount [-a|--all (restores default mounts)] URL|path \n " ;
2008-04-14 07:54:10 +02:00
echo " \t $cmd eacl URL [rwx-] [user or group] \n " ;
2013-04-10 18:46:43 +02:00
echo " \t $cmd lntree [sqlfs://domain]from to \n " ;
2010-03-17 10:11:28 +01:00
echo " \t sudo -u apache $cmd migrate-db2fs --user root_admin --passwd password [--domain default] (migrates sqlfs content from DB to filesystem) \n " ;
2008-09-30 13:52:56 +02:00
2008-03-03 13:18:32 +01:00
echo " \n Common options: --user user --password password [--domain domain] can be used to pass eGW credentials without using the URL writing. \n " ;
2008-09-30 13:52:56 +02:00
echo " \n URL: { vfs|sqlfs|filesystem}://user:password@domain/home/user/file[?option=value&...], /dir/file, ... \n " ;
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
echo " \n Use root_ { header-admin|config-user} as user and according password for root access (no user specific access control and chown). \n \n " ;
2008-09-30 13:52:56 +02:00
exit ;
2007-05-29 10:35:27 +02:00
}
2009-08-27 15:07:56 +02:00
$long = $numeric = $recursive = $perms = $all = $inode = false ;
2008-01-29 08:24:16 +01:00
$argv = $_SERVER [ 'argv' ];
$cmd = basename ( array_shift ( $argv ), '.php' );
2008-02-29 08:29:19 +01:00
if ( $argv [ 0 ][ 0 ] != '-' && $argv [ 0 ][ 0 ] != '/' && strpos ( $argv [ 0 ], '://' ) === false )
{
$cmd = array_shift ( $argv );
}
2008-01-29 08:24:16 +01:00
if ( ! $argv ) $argv = array ( '-h' );
2008-02-29 08:29:19 +01:00
$args = $find_options = array ();
while ( ! is_null ( $option = array_shift ( $argv )))
2007-05-29 10:35:27 +02:00
{
2008-04-14 07:54:10 +02:00
if ( $option == '-' || $option [ 0 ] != '-' ) // no option --> argument
2008-02-29 08:29:19 +01:00
{
$args [] = $option ;
continue ;
}
2008-01-29 08:24:16 +01:00
switch ( $option )
2007-05-29 10:35:27 +02:00
{
2008-01-29 08:24:16 +01:00
default :
2008-02-29 08:29:19 +01:00
if ( $cmd == 'find' )
{
2008-03-02 22:44:15 +01:00
if ( ! in_array ( $option , array ( '-type' , '-depth' , '-mindepth' , '-maxdepth' , '-name' , '-path' ,
2008-02-29 08:29:19 +01:00
'-uid' , '-user' , '-nouser' , '-gid' , '-group' , '-nogroup' , '-mime' ,
2008-03-03 08:53:43 +01:00
'-empty' , '-size' , '-cmin' , '-ctime' , '-mmin' , '-mtime' , '-limit' , '-order' , '-sort' )))
2008-02-29 08:29:19 +01:00
{
usage ();
}
2008-03-02 22:44:15 +01:00
if ( in_array ( $option , array ( '-empty' , '-depth' , '-nouser' , '-nogroup' )))
2008-02-29 08:29:19 +01:00
{
$find_options [ substr ( $option , 1 )] = true ;
}
else
{
$find_options [ substr ( $option , 1 )] = array_shift ( $argv );
}
break ;
}
// multiple options, eg. -rp --> -r -p
elseif ( $option [ 0 ] == '-' && $option [ 1 ] != '-' && strlen ( $option ) > 2 )
{
for ( $i = 1 ; $i < strlen ( $option ); ++ $i )
{
array_unshift ( $argv , '-' . $option [ $i ]);
}
break ;
}
2008-01-29 08:24:16 +01:00
case '-h' : case '--help' :
usage ();
case '-l' : case '--long' :
$long = true ;
2008-02-29 08:29:19 +01:00
break ;
2008-01-29 08:24:16 +01:00
case '-n' : case '--numeric' :
$numeric = true ;
2008-02-29 08:29:19 +01:00
break ;
2008-01-29 08:24:16 +01:00
2008-01-30 07:47:53 +01:00
case '-r' : case '--recursive' :
$recursive = true ;
2008-02-29 08:29:19 +01:00
break ;
2008-09-30 13:52:56 +02:00
2009-08-27 15:07:56 +02:00
case '-i' : case '--inode' :
$inode = true ;
break ;
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
case '-p' : case '--parents' : case '--perms' :
if ( $cmd == 'cp' )
{
$perms = true ;
}
else
{
$recursive = true ;
}
2008-02-29 08:29:19 +01:00
break ;
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
2008-01-30 07:47:53 +01:00
case '-d' : case '--date' :
2008-02-29 08:29:19 +01:00
$time = strtotime ( array_shift ( $argv ));
2008-01-30 07:47:53 +01:00
break ;
2008-09-30 13:52:56 +02:00
2008-03-03 13:18:32 +01:00
case '-a' : case '--all' :
$all = true ;
break ;
2008-09-30 13:52:56 +02:00
2008-03-03 13:18:32 +01:00
case '--user' :
$user = array_shift ( $argv );
break ;
case '--password' :
case '--passwd' :
$passwd = array_shift ( $argv );
break ;
case '--domain' :
$domain = array_shift ( $argv );
break ;
2007-05-29 10:35:27 +02:00
}
2008-01-29 08:24:16 +01:00
}
2008-03-03 13:18:32 +01:00
if ( $user && $passwd )
{
load_egw ( $user , $passwd , $domain ? $domain : 'default' );
}
2008-02-29 08:29:19 +01:00
$argv = $args ;
2008-01-29 08:24:16 +01:00
$argc = count ( $argv );
switch ( $cmd )
{
2008-03-03 13:18:32 +01:00
case 'umount' :
if ( $argc != 1 && ! $all )
{
usage ();
}
if (( $url = $argv [ 0 ])) load_wrapper ( $url );
if ( ! egw_vfs :: $is_root )
{
die ( " You need to be root to do that! \n " );
}
if ( $all )
{
config :: save_value ( 'vfs_fstab' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'vfs_fstab' ] = '' , 'phpgwapi' );
echo " Restored default mounts: \n " ;
}
elseif ( ! egw_vfs :: umount ( $url ))
{
die ( " $url is NOT mounted! \n " );
}
else
{
echo " Successful unmounted $url : \n " ;
}
// fall trough to output current mount table
2008-02-29 08:29:19 +01:00
case 'mount' :
if ( $argc > 2 )
{
usage ();
}
load_wrapper ( $url = $argv [ 0 ]);
2010-02-04 07:21:36 +01:00
2008-03-03 13:18:32 +01:00
if ( $argc > 1 && ! egw_vfs :: $is_root )
{
die ( " You need to be root to do that! \n " );
}
2008-02-29 08:29:19 +01:00
$fstab = egw_vfs :: mount ( $url , $path = $argv [ 1 ]);
if ( is_array ( $fstab ))
{
foreach ( $fstab as $path => $url )
{
echo " $url\t $path\n " ;
}
}
elseif ( $fstab === false )
{
2010-02-04 07:21:36 +01:00
echo " URL ' $url ' not found or permission denied (are you root?)! \n " ;
2008-02-29 08:29:19 +01:00
}
else
{
echo " $url successful mounted to $path\n " ;
}
break ;
2008-04-14 07:54:10 +02:00
case 'eacl' :
do_eacl ( $argv );
break ;
2008-02-29 08:29:19 +01:00
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
case 'find' :
2008-02-29 08:29:19 +01:00
do_find ( $argv , $find_options );
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
break ;
2013-04-10 18:46:43 +02:00
case 'lntree' :
do_lntree ( $argv [ 0 ], $argv [ 1 ]);
break ;
2008-01-29 08:24:16 +01:00
case 'cp' :
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
do_cp ( $argv , $recursive , $perms );
2008-01-29 08:24:16 +01:00
break ;
2008-09-30 13:52:56 +02:00
2008-01-30 07:47:53 +01:00
case 'rename' :
if ( count ( $argv ) != 2 ) usage ( null , 3 );
load_wrapper ( $argv [ 0 ]);
load_wrapper ( $argv [ 1 ]);
rename ( $argv [ 0 ], $argv [ 1 ]);
break ;
2008-09-30 13:52:56 +02:00
2010-03-17 10:11:28 +01:00
case 'migrate-db2fs' :
if ( empty ( $user ) || empty ( $passwd ) || ! egw_vfs :: $is_root )
{
die ( " \n You need to be root to do that! \n \n " );
}
if ( ! is_writable ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'files_dir' ])) exit ; // we need write access, error msg already given
$fstab = egw_vfs :: mount ();
if ( ! is_array ( $fstab ) || ! isset ( $fstab [ '/' ]) || strpos ( $fstab [ '/' ], 'storage=db' ) === false )
{
foreach ( $fstab as $path => $url )
{
echo " $url\t $path\n " ;
}
die ( " \n / NOT mounted with 'storage=db' --> no need to convert! \n \n " );
}
2012-02-27 14:18:52 +01:00
$num_files = sqlfs_utils :: migrate_db2fs (); // throws exception on error
2010-03-17 10:11:28 +01:00
echo " \n $num_files files migrated from DB to filesystem. \n " ;
$new_url = preg_replace ( '/storage=db&?/' , '' , $fstab [ '/' ]);
if ( substr ( $new_url , - 1 ) == '?' ) $new_url = substr ( $new_url , 0 , - 1 );
if ( egw_vfs :: mount ( $new_url , '/' ))
{
echo " / successful re-mounted on $new_url\n " ;
}
else
{
echo " \n re-mounting $new_url on / failed! \n \n " ;
}
break ;
2008-01-29 08:24:16 +01:00
default :
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
while ( $argv )
2008-01-29 08:24:16 +01:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$url = array_shift ( $argv );
2008-01-29 08:24:16 +01:00
load_wrapper ( $url );
2008-09-30 13:52:56 +02:00
echo " $cmd $url (long= " . ( int ) $long . " , numeric= " . ( int ) $numeric . " , recursive= " . ( int ) $recursive . " ) \n " ;
2008-01-30 07:47:53 +01:00
switch ( $cmd )
2008-01-29 08:24:16 +01:00
{
2008-01-30 07:47:53 +01:00
case 'rm' :
2008-04-14 07:54:10 +02:00
if ( $recursive )
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
{
2008-04-14 07:54:10 +02:00
if ( ! class_exists ( 'egw_vfs' ))
{
die ( " rm -r only implemented for eGW streams! " ); // dont want to repeat the code here
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
array_unshift ( $argv , $url );
2008-04-14 07:54:10 +02:00
egw_vfs :: remove ( $argv , true );
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$argv = array ();
}
else
{
unlink ( $url );
}
2008-01-30 07:47:53 +01:00
break ;
case 'rmdir' :
rmdir ( $url );
break ;
case 'mkdir' :
2008-09-30 13:52:56 +02:00
if ( ! mkdir ( $url , null , $recursive )) echo " Can't create directory, permission denied! \n " ;
2008-01-30 07:47:53 +01:00
break ;
2008-09-30 13:52:56 +02:00
2008-01-30 07:47:53 +01:00
case 'touch' :
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
case 'chmod' :
case 'chown' :
case 'chgrp' :
switch ( $cmd )
{
2008-09-30 13:52:56 +02:00
case 'touch' :
$params = array ( $url , $time );
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
break ;
case 'chmod' :
if ( ! isset ( $mode ))
{
$mode = $url ; // first param is mode
$url = array_shift ( $argv );
}
2014-10-18 14:17:17 +02:00
if ( egw_vfs :: parse_url ( $url , PHP_URL_SCHEME )) load_wrapper ( $url ); // cant use stat or egw_vfs::mode2int otherwise!
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( strpos ( $mode , '+' ) !== false || strpos ( $mode , '-' ) !== false )
{
$stat = stat ( $url );
$set = $stat [ 'mode' ];
}
else
{
$set = 0 ;
}
if ( ! class_exists ( 'egw_vfs' ))
{
die ( " chmod only implemented for eGW streams! " ); // dont want to repeat the code here
}
$set = egw_vfs :: mode2int ( $mode , $set );
$params = array ( $url , $set );
break ;
case 'chown' :
case 'chgrp' :
$type = $cmd == 'chgrp' ? 'group' : 'user' ;
if ( ! isset ( $owner ))
{
$owner = $url ; // first param is owner/group
$url = array_shift ( $argv );
2014-10-18 14:17:17 +02:00
if ( egw_vfs :: parse_url ( $url , PHP_URL_SCHEME )) load_wrapper ( $url ); // we need the header loaded
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( $owner == 'root' )
{
$owner = 0 ;
}
elseif ( ! is_numeric ( $owner ))
{
if ( ! is_object ( $GLOBALS [ 'egw' ]))
{
die ( " only numeric user/group-id's allowed for non eGW streams! " );
}
2008-09-30 13:52:56 +02:00
if ( ! ( $owner = $GLOBALS [ 'egw' ] -> accounts -> name2id ( $owner_was = $owner , 'account_lid' , $type [ 0 ])) ||
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
( $owner < 0 ) != ( $cmd == 'chgrp' ))
{
die ( " Unknown $type ' $owner_was '! " );
}
}
elseif ( $owner && is_object ( $GLOBALS [ 'egw' ]) && ( ! $GLOBALS [ 'egw' ] -> accounts -> id2name ( $owner ) ||
( $owner < 0 ) != ( $cmd == 'chgrp' )))
{
die ( " Unknown $type ' $owner_was '! " );
}
}
$params = array ( $url , $owner );
break ;
}
2014-10-18 14:17:17 +02:00
if (( $scheme = egw_vfs :: parse_url ( $url , PHP_URL_SCHEME )))
2008-01-29 08:24:16 +01:00
{
2008-01-30 07:47:53 +01:00
load_wrapper ( $url );
2008-01-29 08:24:16 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( $recursive && class_exists ( 'egw_vfs' ))
2008-01-30 07:47:53 +01:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
array_unshift ( $argv , $url );
$params = array ( $argv , null , $cmd , $params [ 1 ]);
$cmd = array ( 'egw_vfs' , 'find' );
$argv = array (); // we processed all url's
2008-01-30 07:47:53 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
//echo "calling cmd=".print_r($cmd,true).", params=".print_r($params,true)."\n";
call_user_func_array ( $cmd , $params );
2008-01-30 07:47:53 +01:00
break ;
case 'cat' :
case 'ls' :
default :
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
// recursive ls atm only for vfs://
if ( $cmd != 'cat' && $recursive && class_exists ( 'egw_vfs' ))
{
load_wrapper ( $url );
array_unshift ( $argv , $url );
2009-08-27 15:07:56 +02:00
egw_vfs :: find ( $argv , array ( 'url' => true ,), 'do_stat' , array ( $long , $numeric , true , $inode ));
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$argv = array ();
}
elseif ( is_dir ( $url ) && ( $dir = opendir ( $url )))
2008-01-30 07:47:53 +01:00
{
if ( $argc )
{
2014-10-18 14:17:17 +02:00
if ( ! ( $name = basename ( egw_vfs :: parse_url ( $url , PHP_URL_PATH )))) $name = '/' ;
2008-02-29 08:29:19 +01:00
echo " \n $name : \n " ;
}
2008-09-30 13:52:56 +02:00
// separate evtl. query part, to re-add it after the file-name
$query = '' ;
list ( $url , $query ) = explode ( '?' , $url , 2 );
if ( $query ) $query = '?' . $query ;
2008-02-29 08:29:19 +01:00
if ( substr ( $url , - 1 ) == '/' )
{
$url = substr ( $url , 0 , - 1 );
2008-01-30 07:47:53 +01:00
}
while (( $file = readdir ( $dir )) !== false )
{
2009-08-27 15:07:56 +02:00
do_stat ( $url . '/' . $file . $query , $long , $numeric , false , $inode );
2008-01-30 07:47:53 +01:00
}
closedir ( $dir );
}
elseif ( $cmd == 'cat' )
{
if ( ! ( $f = fopen ( $url , 'r' )))
{
echo " File $url not found !!! \n \n " ;
}
else
{
if ( $argc )
{
2014-10-18 14:17:17 +02:00
echo " \n " . basename ( egw_vfs :: parse_url ( $url , PHP_URL_PATH )) . " : \n " ;
2008-01-30 07:47:53 +01:00
}
fpassthru ( $f );
fclose ( $f );
}
}
else
{
2009-08-27 15:07:56 +02:00
do_stat ( $url , $long , $numeric , false , $inode );
2008-01-30 07:47:53 +01:00
}
if ( ! $long && $cmd == 'ls' ) echo " \n " ;
break ;
2008-01-29 08:24:16 +01:00
}
}
}
/**
2009-04-01 16:08:20 +02:00
* Load the necessary wrapper for an url or die if it cant be loaded
2008-01-29 08:24:16 +01:00
*
* @ param string $url
*/
function load_wrapper ( $url )
{
2015-04-17 16:07:49 +02:00
$scheme = parse_url ( $url , PHP_URL_SCHEME );
2010-03-17 10:11:28 +01:00
2008-04-14 07:54:10 +02:00
if ( ! in_array ( $scheme , stream_get_wrappers ()))
2007-05-29 10:35:27 +02:00
{
2008-04-14 07:54:10 +02:00
switch ( $scheme )
{
case 'webdav' :
2012-01-11 22:24:54 +01:00
case 'webdavs' :
2008-04-14 07:54:10 +02:00
require_once ( 'HTTP/WebDAV/Client.php' );
break ;
2013-04-10 18:46:43 +02:00
case '' : // default scheme is file and always available
2008-04-14 07:54:10 +02:00
break ;
default :
if ( ! isset ( $GLOBALS [ 'egw' ]) && ! in_array ( $scheme , array ( 'smb' , 'imap' )))
{
2015-04-17 16:07:49 +02:00
load_egw ( parse_url ( $url , PHP_URL_USER ), parse_url ( $url , PHP_URL_PASS ), parse_url ( $url , PHP_URL_HOST ));
2008-04-14 07:54:10 +02:00
}
2009-04-01 16:08:20 +02:00
// get eGW's __autoload() function
include_once ( EGW_API_INC . '/common_functions.inc.php' );
2008-04-14 07:54:10 +02:00
2015-02-19 10:43:06 +01:00
if ( ! egw_vfs :: load_wrapper ( $scheme ))
2008-04-14 07:54:10 +02:00
{
die ( " Unknown scheme ' $scheme ' in $url !!! \n \n " );
}
break ;
}
2007-05-29 10:35:27 +02:00
}
}
2008-03-03 13:18:32 +01:00
/**
* Start the eGW session , exits on wrong credintials
*
* @ param string $user
* @ param string $passwd
* @ param string $domain
*/
function load_egw ( $user , $passwd , $domain = 'default' )
{
2008-03-06 07:03:18 +01:00
//echo "load_egw($user,$passwd,$domain)\n";
2009-11-30 18:57:07 +01:00
$_REQUEST [ 'domain' ] = $domain ;
2008-03-03 13:18:32 +01:00
$GLOBALS [ 'egw_login_data' ] = array (
'login' => $user ,
'passwd' => $passwd ,
'passwd_type' => 'text' ,
);
2008-09-30 13:52:56 +02:00
2008-03-06 07:03:18 +01:00
if ( ini_get ( 'session.save_handler' ) == 'files' && ! is_writable ( ini_get ( 'session.save_path' )) && is_dir ( '/tmp' ) && is_writable ( '/tmp' ))
{
ini_set ( 'session.save_path' , '/tmp' ); // regular users may have no rights to apache's session dir
}
2008-09-30 13:52:56 +02:00
2008-03-03 13:18:32 +01:00
$GLOBALS [ 'egw_info' ] = array (
'flags' => array (
'currentapp' => 'filemanager' ,
'noheader' => true ,
'autocreate_session_callback' => 'user_pass_from_argv' ,
2008-10-26 13:15:26 +01:00
'no_exception_handler' => 'cli' ,
2008-03-03 13:18:32 +01:00
)
);
2008-09-30 13:52:56 +02:00
2008-03-03 13:18:32 +01:00
if ( substr ( $user , 0 , 5 ) != 'root_' )
{
include ( '../header.inc.php' );
}
else
{
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ] = 'login' ;
include ( '../header.inc.php' );
2008-09-30 13:52:56 +02:00
2008-03-03 13:18:32 +01:00
if ( $user == 'root_' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'header_admin_user' ] &&
_check_pw ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'header_admin_password' ], $passwd ) ||
2010-02-04 07:21:36 +01:00
$user == 'root_' . $GLOBALS [ 'egw_domain' ][ $domain ][ 'config_user' ] &&
_check_pw ( $GLOBALS [ 'egw_domain' ][ $domain ][ 'config_passwd' ], $passwd ))
2008-03-03 13:18:32 +01:00
{
echo " \n Root access granted! \n " ;
egw_vfs :: $is_root = true ;
}
else
{
die ( " Unknown user or password! \n " );
}
}
2008-09-30 13:52:56 +02:00
2008-03-03 13:18:32 +01:00
$cmd = $GLOBALS [ 'cmd' ];
2008-04-14 07:54:10 +02:00
if ( ! in_array ( $cmd , array ( 'ls' , 'find' , 'mount' , 'umount' , 'eacl' )) && $GLOBALS [ 'egw_info' ][ 'server' ][ 'files_dir' ] && ! is_writable ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'files_dir' ]))
2008-03-03 13:18:32 +01:00
{
echo " \n Error: eGroupWare's files directory { $GLOBALS [ 'egw_info' ][ 'server' ][ 'files_dir' ] } is NOT writable by the user running " . basename ( __FILE__ ) . " ! \n " .
" --> Please run it as the same user the webserver uses or root, otherwise the $cmd command will fail! \n \n " ;
}
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
/**
* Check password against a md5 hash or cleartext password
*
* @ param string $hash_or_cleartext
* @ param string $pw
* @ return boolean
*/
function _check_pw ( $hash_or_cleartext , $pw )
{
//echo "_check_pw($hash_or_cleartext,$pw) md5=".md5($pw)."\n";
if ( preg_match ( '/^[0-9a-f]{32}$/' , $hash_or_cleartext ))
{
return $hash_or_cleartext == md5 ( $pw );
}
return $hash_or_cleartext == $pw ;
}
2008-04-14 07:54:10 +02:00
/**
* Set , delete or show the extended acl for a given path
*
* @ param array $argv
*/
function do_eacl ( array $argv )
{
$argc = count ( $argv );
if ( $argc < 1 || $argc > 3 )
{
usage ();
}
load_wrapper ( $url = $argv [ 0 ]);
if ( ! class_exists ( 'egw_vfs' ))
{
die ( 'eacl only implemented for eGW streams!' );
}
if ( ! file_exists ( $url ))
{
die ( " $url : no such file our directory! \n " );
}
if ( $argc == 1 )
{
foreach ( egw_vfs :: get_eacl ( $url ) as $acl )
{
$mode = ( $acl [ 'rights' ] & egw_vfs :: READABLE ? 'r' : '-' ) .
( $acl [ 'rights' ] & egw_vfs :: WRITABLE ? 'w' : '-' ) .
( $acl [ 'rights' ] & egw_vfs :: EXECUTABLE ? 'x' : '-' );
echo $acl [ 'path' ] . " \t $mode\t " . $GLOBALS [ 'egw' ] -> accounts -> id2name ( $acl [ 'owner' ]) . " \n " ;
}
return ;
}
if ( $argc > 1 && ! is_numeric ( $argv [ 1 ]))
{
$mode = $argv [ 1 ];
$argv [ 1 ] = null ;
for ( $i = 0 ; $mode [ $i ]; ++ $i )
{
switch ( $mode [ $i ])
{
case 'x' : $argv [ 1 ] |= egw_vfs :: EXECUTABLE ; break ;
case 'w' : $argv [ 1 ] |= egw_vfs :: WRITABLE ; break ;
case 'r' : $argv [ 1 ] |= egw_vfs :: READABLE ; break ;
}
}
}
if ( ! egw_vfs :: eacl ( $url , $argv [ 1 ], $argc > 2 && ! is_numeric ( $argv [ 2 ]) ? $GLOBALS [ 'egw' ] -> accounts -> name2id ( $argv [ 2 ]) : $argv [ 2 ]))
{
echo " Error setting extended acl for $argv[0] ! \n " ;
}
}
2008-01-29 08:24:16 +01:00
/**
* Give the stats for one file
*
* @ param string $url
* @ param boolean $long = false true = long listing with owner , group , size , perms , default false only filename
* @ param boolean $numeric = false true = give numeric uid & gid , else resolve the id to a name
2009-08-27 15:07:56 +02:00
* @ param boolean $full_path = false true = give full path instead of just filename
* @ param boolean $inode = false true = display inode ( sqlfs id )
2008-01-29 08:24:16 +01:00
*/
2009-08-27 15:07:56 +02:00
function do_stat ( $url , $long = false , $numeric = false , $full_path = false , $inode = false )
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
//echo "do_stat($url,$long,$numeric,$full_path)\n";
2014-10-18 14:17:17 +02:00
$bname = egw_vfs :: parse_url ( $url , PHP_URL_PATH );
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( ! $full_path )
{
$bname = basename ( $bname );
}
2009-05-02 14:45:06 +02:00
if ( ! ( $stat = @ lstat ( $url )))
2008-04-14 07:54:10 +02:00
{
echo " $bname : no such file or directory! \n " ;
}
elseif ( $long )
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
//echo $url; print_r($stat);
2008-09-30 13:52:56 +02:00
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( class_exists ( 'egw_vfs' ))
{
$perms = egw_vfs :: int2mode ( $stat [ 'mode' ]);
}
else
{
$perms = int2mode ( $stat [ 'mode' ]);
}
2008-01-29 08:24:16 +01:00
if ( $numeric )
{
$uid = $stat [ 'uid' ];
$gid = $stat [ 'gid' ];
}
else
{
if ( $stat [ 'uid' ])
{
2008-09-30 13:52:56 +02:00
$uid = isset ( $GLOBALS [ 'egw' ]) ? $GLOBALS [ 'egw' ] -> accounts -> id2name ( $stat [ 'uid' ]) :
( function_exists ( 'posix_getpwuid' ) ? posix_getpwuid ( $stat [ 'uid' ]) : $stat [ 'uid' ]);
2008-01-29 08:24:16 +01:00
if ( is_array ( $uid )) $uid = $uid [ 'name' ];
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( empty ( $uid )) $uid = $stat [ 'uid' ];
2008-01-29 08:24:16 +01:00
}
2008-01-30 07:47:53 +01:00
if ( ! isset ( $uid )) $uid = 'root' ;
2008-01-29 08:24:16 +01:00
if ( $stat [ 'gid' ])
{
2008-09-30 13:52:56 +02:00
$gid = isset ( $GLOBALS [ 'egw' ]) ? $GLOBALS [ 'egw' ] -> accounts -> id2name ( - abs ( $stat [ 'gid' ])) :
( function_exists ( 'posix_getgrgid' ) ? posix_getgrgid ( $stat [ 'gid' ]) : $stat [ 'gid' ]);
2008-01-29 08:24:16 +01:00
if ( is_array ( $gid )) $gid = $gid [ 'name' ];
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( empty ( $gid )) $gid = $stat [ 'gid' ];
2008-01-29 08:24:16 +01:00
}
2008-01-30 07:47:53 +01:00
if ( ! isset ( $gid )) $gid = 'root' ;
2008-01-29 08:24:16 +01:00
}
2007-05-29 10:35:27 +02:00
$size = hsize ( $stat [ 'size' ]);
$mtime = date ( 'Y-m-d H:i:s' , $stat [ 'mtime' ]);
$nlink = $stat [ 'nlink' ];
2009-03-24 17:27:29 +01:00
if (( $stat [ 'mode' ] & 0xA000 ) == 0xA000 )
{
$symlink = " -> " . ( class_exists ( 'egw_vfs' ) ? egw_vfs :: readlink ( $url ) : readlink ( $url ));
}
2009-08-27 15:07:56 +02:00
if ( $inode )
{
echo $stat [ 'ino' ] . " \t " ;
}
2009-03-24 17:27:29 +01:00
echo " $perms $nlink\t $uid\t $gid\t $size\t $mtime\t $bname $symlink\n " ;
2007-05-29 10:35:27 +02:00
}
else
{
echo " $bname\t " ;
}
}
function hsize ( $size )
{
if ( $size < 1024 ) return $size ;
if ( $size < 1024 * 1024 ) return sprintf ( '%3.1lfk' ,( float ) $size / 1024 );
return sprintf ( '%3.1lfM' ,( float ) $size / ( 1024 * 1024 ));
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
function do_cp ( $argv , $recursive = false , $perms = false )
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$to = array_pop ( $argv );
load_wrapper ( $to );
$to_exists = file_exists ( $to );
if ( count ( $argv ) > 1 && $to_exists && ! is_dir ( $to ))
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
usage ( null , 4 );
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
foreach ( $argv as $from )
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( is_dir ( $from ) && ( ! file_exists ( $to ) || is_dir ( $to )) && $recursive && class_exists ( 'egw_vfs' ))
{
2008-03-02 22:44:15 +01:00
foreach ( egw_vfs :: find ( $from , array ( 'url' => true )) as $f )
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
{
$t = $to . substr ( $f , strlen ( $from ));
if ( is_dir ( $f ))
{
++ $anz_dirs ;
mkdir ( $t );
}
else
{
++ $anz_files ;
_cp ( $f , $t );
}
if ( $perms ) _cp_perms ( $f , $t );
}
echo ( $anz_dirs ? " $anz_dirs dir(s) created and " : '' ) . " $anz_files file(s) copied. \n " ;
}
else
{
_cp ( $from , $to , true );
if ( $perms ) _cp_perms ( $from , $to );
}
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
}
function _cp ( $from , $to , $verbose = false , $perms = false )
{
load_wrapper ( $from );
if ( is_dir ( $to ) || ! file_exists ( $to ) && is_dir ( $from ) && $mkdir )
2007-05-29 10:35:27 +02:00
{
2014-10-18 14:17:17 +02:00
$path = egw_vfs :: parse_url ( $from , PHP_URL_PATH );
2008-09-30 13:52:56 +02:00
if ( is_dir ( $to ))
{
list ( $to , $query ) = explode ( '?' , $to , 2 );
$to .= '/' . basename ( $path ) . ( $query ? '?' . $query : '' );
}
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( ! ( $from_fp = fopen ( $from , 'r' )))
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
die ( " File $from not found! \n " );
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( ! ( $to_fp = fopen ( $to , 'w' )))
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
die ( " Can't open $to for writing! \n " );
2007-05-29 10:35:27 +02:00
}
2008-04-14 07:54:10 +02:00
//stream_filter_append($from_fp,'convert.base64-decode');
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$count = stream_copy_to_stream ( $from_fp , $to_fp );
2008-09-30 13:52:56 +02:00
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( $verbose ) echo hsize ( $count ) . " bytes written to $to\n " ;
2008-09-30 13:52:56 +02:00
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
fclose ( $from_fp );
2008-09-30 13:52:56 +02:00
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( ! fclose ( $to_fp ))
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
die ( " Error closing $to ! \n " );
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
}
function _cp_perms ( $from , $to )
{
if (( $from_stat = stat ( $from )) && ( $to_stat = stat ( $to )))
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
foreach ( array (
'mode' => 'chmod' ,
'uid' => 'chown' ,
'gid' => 'chgrp' ,
) as $perm => $cmd )
{
if ( $from_stat [ $perm ] != $to_stat [ $perm ])
{
//echo "egw_vfs::$cmd($to,{$from_stat[$perm]}\n";
call_user_func ( array ( 'egw_vfs' , $cmd ), $to , $from_stat [ $perm ]);
}
}
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
}
2008-02-29 08:29:19 +01:00
function do_find ( $bases , $options )
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
{
foreach ( $bases as $url )
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
load_wrapper ( $url );
2007-05-29 10:35:27 +02:00
}
2008-03-02 22:44:15 +01:00
$options [ 'url' ] = true ; // we use url's not vfs pathes in filemanager/cli.php
2008-02-29 08:29:19 +01:00
foreach ( egw_vfs :: find ( $bases , $options ) as $path )
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
{
echo " $path\n " ;
}
}
2007-05-29 10:35:27 +02:00
2013-04-10 18:46:43 +02:00
function do_lntree ( $from , $to )
{
echo " lntree $from $to\n " ;
if ( $from [ 0 ] == '/' ) $from = 'sqlfs://default' . $from ;
load_wrapper ( $from );
if ( ! file_exists ( $from ) || $to [ 0 ] != '/' || file_exists ( $to ) || ! is_writable ( dirname ( $to )))
{
usage ( null , 4 );
}
egw_vfs :: find ( $from , array (
'url' => true ,
), '_ln' , array ( $to ));
}
function _ln ( $src , $base , $stat )
{
//echo "_ln('$src', '$base', ".array2string($stat).")\n";
2014-10-18 14:17:17 +02:00
$dst = $base . egw_vfs :: parse_url ( $src , PHP_URL_PATH );
2013-04-10 18:46:43 +02:00
if ( is_link ( $src ))
{
if (( $target = sqlfs_stream_wrapper :: readlink ( $src )))
{
if ( $target [ 0 ] != '/' )
{
$target = egw_vfs :: dirname ( $src ) . '/' . $target ;
}
echo " _ln(' $src ', ' $base ') \t symlink(' $base $target ', ' $dst ') \n " ;
symlink ( $base . $target , $dst );
}
else
{
echo " _ln(' $src ', ' $base ') \t sqlfs::readlink(' $src ') failed \n " ;
}
}
elseif ( is_dir ( $src ))
{
echo " _ln(' $src ', ' $base ') \t mkdir(' $dst ', 0700, true) \n " ;
mkdir ( $dst , 0700 , true );
}
else
{
$target = sqlfs_stream_wrapper :: _fs_path ( $stat [ 'ino' ]);
echo " _ln(' $src ', ' $base ') \t link(' $target ', ' $dst ') \n " ;
link ( $target , $dst );
}
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
/**
* Convert a numerical mode to a symbolic mode - string
*
* @ param int $mode
* @ return string
*/
function int2mode ( $mode )
2008-01-29 08:24:16 +01:00
{
2009-03-24 17:27:29 +01:00
if (( $mode & 0xA000 ) == 0xA000 ) // Symbolic Link
{
$sP = 'l' ;
}
elseif (( $mode & 0xC000 ) == 0xC000 ) // Socket
{
$sP = 's' ;
}
elseif ( $mode & 0x1000 ) // FIFO pipe
2008-01-29 08:24:16 +01:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$sP = 'p' ;
2008-01-29 08:24:16 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
elseif ( $mode & 0x2000 ) // Character special
2008-01-29 08:24:16 +01:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$sP = 'c' ;
2008-01-29 08:24:16 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
elseif ( $mode & 0x4000 ) // Directory
2008-01-29 08:24:16 +01:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$sP = 'd' ;
2008-01-29 08:24:16 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
elseif ( $mode & 0x6000 ) // Block special
2008-01-29 08:24:16 +01:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$sP = 'b' ;
2008-01-29 08:24:16 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
elseif ( $mode & 0x8000 ) // Regular
2008-01-29 08:24:16 +01:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$sP = '-' ;
2008-01-29 08:24:16 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
else // UNKNOWN
{
$sP = 'u' ;
2008-01-29 08:24:16 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
// owner
$sP .= (( $mode & 0x0100 ) ? 'r' : '-' ) .
(( $mode & 0x0080 ) ? 'w' : '-' ) .
(( $mode & 0x0040 ) ? (( $mode & 0x0800 ) ? 's' : 'x' ) :
(( $mode & 0x0800 ) ? 'S' : '-' ));
// group
$sP .= (( $mode & 0x0020 ) ? 'r' : '-' ) .
(( $mode & 0x0010 ) ? 'w' : '-' ) .
(( $mode & 0x0008 ) ? (( $mode & 0x0400 ) ? 's' : 'x' ) :
(( $mode & 0x0400 ) ? 'S' : '-' ));
// world
$sP .= (( $mode & 0x0004 ) ? 'r' : '-' ) .
(( $mode & 0x0002 ) ? 'w' : '-' ) .
(( $mode & 0x0001 ) ? (( $mode & 0x0200 ) ? 't' : 'x' ) :
(( $mode & 0x0200 ) ? 'T' : '-' ));
return $sP ;
2008-01-29 08:24:16 +01:00
}