2008-09-30 13:52:56 +02:00
#!/usr/bin/php -qC
2007-05-29 10:35:27 +02:00
< ? php
/**
2016-05-05 09:20:07 +02:00
* EGroupware 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 >
2017-04-05 10:02:00 +02:00
* @ copyright ( c ) 2007 - 17 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
*/
2016-05-05 09:20:07 +02:00
use EGroupware\Api ;
use EGroupware\Api\Vfs ;
2007-05-29 10:35:27 +02:00
chdir ( dirname ( __FILE__ )); // to enable our relative pathes to work
2016-02-15 12:10:23 +01:00
error_reporting ( error_reporting () & ~ E_NOTICE & ~ E_DEPRECATED );
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
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 )))
{
2016-02-15 12:10:23 +01:00
usage ( " Wrong username or -password! " );
2007-05-29 10:35:27 +02:00
}
return $sessionid ;
}
/**
* Give a usage message and exit
2016-02-15 12:10:23 +01:00
*
* @ param string $error_msg = '' error - message to be printed in front of usage
2007-05-29 10:35:27 +02:00
*/
2016-02-15 12:10:23 +01:00
function usage ( $error_msg = '' )
2007-05-29 10:35:27 +02:00
{
2016-02-15 12:10:23 +01:00
if ( $error_msg )
{
echo " $error_msg\n\n " ;
}
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 " ;
2016-01-21 12:49:50 +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)][-hidden][-show-deleted][-(name|name-preg|path|path-preg) S] \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 ;
2016-01-21 12:49:50 +01:00
$args = $_SERVER [ 'argv' ];
$cmd = basename ( array_shift ( $args ), '.php' );
if ( $args [ 0 ][ 0 ] != '-' && $args [ 0 ][ 0 ] != '/' && strpos ( $args [ 0 ], '://' ) === false )
2008-02-29 08:29:19 +01:00
{
2016-01-21 12:49:50 +01:00
$cmd = array_shift ( $args );
2008-02-29 08:29:19 +01:00
}
2008-01-29 08:24:16 +01:00
2016-01-21 12:49:50 +01:00
if ( ! $args ) $args = array ( '-h' );
2008-01-29 08:24:16 +01:00
2016-01-21 12:49:50 +01:00
$argv = $find_options = array ();
while ( ! is_null ( $option = array_shift ( $args )))
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
{
2016-01-21 12:49:50 +01:00
$argv [] = $option ;
2008-02-29 08:29:19 +01:00
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' ,
2016-01-21 12:49:50 +01:00
'-empty' , '-size' , '-cmin' , '-ctime' , '-mmin' , '-mtime' , '-limit' , '-order' , '-sort' ,
'-hidden' , '-show-deleted' , '-name-preg' , '-path' , '-path-preg' )))
2008-02-29 08:29:19 +01:00
{
2016-02-15 12:10:23 +01:00
usage ( " Unknown find option ' $option '! " );
2008-02-29 08:29:19 +01:00
}
2016-01-21 12:49:50 +01:00
if ( in_array ( $option , array ( '-empty' , '-depth' , '-nouser' , '-nogroup' , '-hidden' , '-show-deleted' )))
2008-02-29 08:29:19 +01:00
{
$find_options [ substr ( $option , 1 )] = true ;
}
else
{
2016-01-21 12:49:50 +01:00
$find_options [ str_replace ( '-' , '_' , substr ( $option , 1 ))] = array_shift ( $args );
2008-02-29 08:29:19 +01:00
}
break ;
}
// multiple options, eg. -rp --> -r -p
elseif ( $option [ 0 ] == '-' && $option [ 1 ] != '-' && strlen ( $option ) > 2 )
{
for ( $i = 1 ; $i < strlen ( $option ); ++ $i )
{
2016-01-21 12:49:50 +01:00
array_unshift ( $args , '-' . $option [ $i ]);
2008-02-29 08:29:19 +01:00
}
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' :
2016-01-21 12:49:50 +01:00
$time = strtotime ( array_shift ( $args ));
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' :
2016-01-21 12:49:50 +01:00
$user = array_shift ( $args );
2008-03-03 13:18:32 +01:00
break ;
case '--password' :
case '--passwd' :
2016-01-21 12:49:50 +01:00
$passwd = array_shift ( $args );
2008-03-03 13:18:32 +01:00
break ;
case '--domain' :
2016-01-21 12:49:50 +01:00
$domain = array_shift ( $args );
2008-03-03 13:18:32 +01:00
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-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 )
{
2016-02-15 12:10:23 +01:00
usage ( 'Wrong number of parameters!' );
2008-03-03 13:18:32 +01:00
}
if (( $url = $argv [ 0 ])) load_wrapper ( $url );
2016-05-05 09:20:07 +02:00
if ( ! Vfs :: $is_root )
2008-03-03 13:18:32 +01:00
{
die ( " You need to be root to do that! \n " );
}
if ( $all )
{
2016-05-05 09:20:07 +02:00
Api\Config :: save_value ( 'vfs_fstab' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'vfs_fstab' ] = '' , 'phpgwapi' );
2008-03-03 13:18:32 +01:00
echo " Restored default mounts: \n " ;
}
2016-05-05 09:20:07 +02:00
elseif ( ! Vfs :: umount ( $url ))
2008-03-03 13:18:32 +01:00
{
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 )
{
2016-02-15 12:10:23 +01:00
usage ( 'Wrong number of parameters!' );
2008-02-29 08:29:19 +01:00
}
load_wrapper ( $url = $argv [ 0 ]);
2010-02-04 07:21:36 +01:00
2016-05-05 09:20:07 +02:00
if ( $argc > 1 && ! Vfs :: $is_root )
2008-03-03 13:18:32 +01:00
{
die ( " You need to be root to do that! \n " );
}
2016-05-05 09:20:07 +02:00
$fstab = Vfs :: mount ( $url , $path = $argv [ 1 ]);
2008-02-29 08:29:19 +01:00
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' :
2016-02-15 12:10:23 +01:00
if ( count ( $argv ) != 2 ) usage ( 'Wrong number of parameters!' );
2008-01-30 07:47:53 +01:00
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' :
2016-05-05 09:20:07 +02:00
if ( empty ( $user ) || empty ( $passwd ) || ! Vfs :: $is_root )
2010-03-17 10:11:28 +01:00
{
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
2016-05-05 09:20:07 +02:00
$fstab = Vfs :: mount ();
2010-03-17 10:11:28 +01:00
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 " );
}
2016-05-05 09:20:07 +02:00
$num_files = Vfs\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 );
2016-05-05 09:20:07 +02:00
if ( Vfs :: mount ( $new_url , '/' ))
2010-03-17 10:11:28 +01:00
{
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
{
2017-04-05 10:02:00 +02:00
if ( ! class_exists ( 'EGroupware\\Api\\Vfs' ))
2008-04-14 07:54:10 +02:00
{
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 );
2016-05-05 09:20:07 +02:00
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 );
}
2016-05-05 09:20:07 +02:00
if ( Vfs :: parse_url ( $url , PHP_URL_SCHEME )) load_wrapper ( $url ); // cant use stat or 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 ;
}
2017-04-05 10:02:00 +02:00
if ( ! class_exists ( 'EGroupware\\Api\\Vfs' ))
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 ( " chmod only implemented for eGW streams! " ); // dont want to repeat the code here
}
2016-05-05 09:20:07 +02:00
$set = Vfs :: mode2int ( $mode , $set );
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
$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 );
2016-05-05 09:20:07 +02:00
if ( 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 ;
}
2016-05-05 09:20:07 +02:00
if (( $scheme = 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
}
2017-04-05 10:02:00 +02:00
if ( $recursive && class_exists ( 'EGroupware\\Api\\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 ]);
2017-04-05 10:02:00 +02:00
$cmd = array ( 'EGroupware\\Api\\Vfs' , 'find' );
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 (); // 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://
2017-04-05 10:02:00 +02:00
if ( $cmd != 'cat' && $recursive && class_exists ( 'EGroupware\\Api\\Vfs' ))
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 );
array_unshift ( $argv , $url );
2016-05-05 09:20:07 +02:00
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 )
{
2016-05-05 09:20:07 +02:00
if ( ! ( $name = basename ( 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
2016-01-21 12:49:50 +01:00
unset ( $query );
2008-09-30 13:52:56 +02:00
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 )
{
2016-05-05 09:20:07 +02:00
echo " \n " . basename ( 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 )
{
2016-07-02 12:26:39 +02:00
if (( $scheme = parse_url ( $url , PHP_URL_SCHEME )) &&
! 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 ;
2016-07-02 12:26:39 +02:00
2008-04-14 07:54:10 +02:00
default :
2016-07-02 12:26:39 +02:00
if ( ! isset ( $GLOBALS [ 'egw' ]) && ! in_array ( $scheme , array ( 'smb' , 'imap' )) &&
( $user = parse_url ( $url , PHP_URL_USER )) && ( $pass = parse_url ( $url , PHP_URL_PASS )))
2008-04-14 07:54:10 +02:00
{
2016-07-02 12:26:39 +02:00
load_egw ( $user , $pass , ( $host = parse_url ( $url , PHP_URL_HOST )) ? $host : 'default' );
2008-04-14 07:54:10 +02:00
}
2009-04-01 16:08:20 +02:00
// get eGW's __autoload() function
2016-07-02 12:26:39 +02:00
include_once ( EGW_SERVER_ROOT . '/api/src/loader/common.php' );
2008-04-14 07:54:10 +02:00
2016-05-05 09:20:07 +02:00
if ( ! 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
2016-02-15 12:10:23 +01:00
if ( setup :: check_auth ( $user , $passwd ,
'root_' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'header_admin_user' ],
$GLOBALS [ 'egw_info' ][ 'server' ][ 'header_admin_password' ]) ||
setup :: check_auth ( $user , $passwd ,
'root_' . $GLOBALS [ 'egw_domain' ][ $domain ][ 'config_user' ],
$GLOBALS [ 'egw_domain' ][ $domain ][ 'config_passwd' ]))
2008-03-03 13:18:32 +01:00
{
echo " \n Root access granted! \n " ;
2016-05-05 09:20:07 +02:00
Vfs :: $is_root = true ;
2008-03-03 13:18:32 +01:00
}
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 " ;
}
}
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 )
{
2016-02-15 12:10:23 +01:00
usage ( 'Wrong number of parameters!' );
2008-04-14 07:54:10 +02:00
}
load_wrapper ( $url = $argv [ 0 ]);
2017-04-05 10:02:00 +02:00
if ( ! class_exists ( 'EGroupware\\Api\\Vfs' ))
2008-04-14 07:54:10 +02:00
{
die ( 'eacl only implemented for eGW streams!' );
}
if ( ! file_exists ( $url ))
{
die ( " $url : no such file our directory! \n " );
}
if ( $argc == 1 )
{
2016-05-05 09:20:07 +02:00
foreach ( Vfs :: get_eacl ( $url ) as $acl )
2008-04-14 07:54:10 +02:00
{
2016-05-05 09:20:07 +02:00
$mode = ( $acl [ 'rights' ] & Vfs :: READABLE ? 'r' : '-' ) .
( $acl [ 'rights' ] & Vfs :: WRITABLE ? 'w' : '-' ) .
( $acl [ 'rights' ] & Vfs :: EXECUTABLE ? 'x' : '-' );
2008-04-14 07:54:10 +02:00
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 ])
{
2016-05-05 09:20:07 +02:00
case 'x' : $argv [ 1 ] |= Vfs :: EXECUTABLE ; break ;
case 'w' : $argv [ 1 ] |= Vfs :: WRITABLE ; break ;
case 'r' : $argv [ 1 ] |= Vfs :: READABLE ; break ;
2008-04-14 07:54:10 +02:00
}
}
}
2016-05-05 09:20:07 +02:00
if ( ! Vfs :: eacl ( $url , $argv [ 1 ], $argc > 2 && ! is_numeric ( $argv [ 2 ]) ? $GLOBALS [ 'egw' ] -> accounts -> name2id ( $argv [ 2 ]) : $argv [ 2 ]))
2008-04-14 07:54:10 +02:00
{
2016-05-05 09:20:07 +02:00
echo " Error setting extended Acl for $argv[0] ! \n " ;
2008-04-14 07:54:10 +02:00
}
}
2008-01-29 08:24:16 +01:00
/**
* Give the stats for one file
*
* @ param string $url
2016-01-21 12:49:50 +01:00
* @ 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
* @ 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";
2016-05-05 09:20:07 +02:00
$bname = 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
2017-04-05 10:02:00 +02:00
if ( class_exists ( 'EGroupware\\Api\\Vfs' ))
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
{
2016-05-05 09:20:07 +02:00
$perms = Vfs :: int2mode ( $stat [ 'mode' ]);
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
{
$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 )
{
2017-04-05 10:02:00 +02:00
$symlink = " -> " . ( class_exists ( 'EGroupware\\Api\\Vfs' ) ? Vfs :: readlink ( $url ) : readlink ( $url ));
2009-03-24 17:27:29 +01:00
}
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
{
2016-02-15 12:10:23 +01:00
usage ( " No such directory ' $to '! " );
2007-05-29 10:35:27 +02:00
}
2016-01-21 12:49:50 +01:00
$anz_dirs = $anz_files = 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
foreach ( $argv as $from )
2007-05-29 10:35:27 +02:00
{
2017-04-05 10:02:00 +02:00
if ( is_dir ( $from ) && ( ! file_exists ( $to ) || is_dir ( $to )) && $recursive && class_exists ( 'EGroupware\\Api\\Vfs' ))
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
{
2016-05-05 09:20:07 +02:00
foreach ( 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
}
2016-01-21 12:49:50 +01:00
function _cp ( $from , $to , $verbose = false )
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 ( $from );
2016-01-21 12:49:50 +01:00
if ( is_dir ( $to ))
2007-05-29 10:35:27 +02:00
{
2016-05-05 09:20:07 +02:00
$path = 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 ])
{
2017-04-05 10:02:00 +02:00
//echo "Vfs::$cmd($to,{$from_stat[$perm]}\n";
call_user_func ( array ( 'EGroupware\\Api\\Vfs' , $cmd ), $to , $from_stat [ $perm ]);
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
}
}
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
2016-05-05 09:20:07 +02:00
foreach ( 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 );
2016-02-15 12:10:23 +01:00
if ( ! file_exists ( $from ))
{
usage ( " Directory ' $from ' does NOT exist! " );
}
elseif ( $to [ 0 ] != '/' || file_exists ( $to ))
{
usage ( " Directory ' $to ' does not exist! " );
}
elseif ( ! is_writable ( dirname ( $to )))
2013-04-10 18:46:43 +02:00
{
2016-02-15 12:10:23 +01:00
usage ( " Directory ' $to ' is not writable! " );
2013-04-10 18:46:43 +02:00
}
2016-05-05 09:20:07 +02:00
Vfs :: find ( $from , array (
2013-04-10 18:46:43 +02:00
'url' => true ,
), '_ln' , array ( $to ));
}
function _ln ( $src , $base , $stat )
{
//echo "_ln('$src', '$base', ".array2string($stat).")\n";
2016-05-05 09:20:07 +02:00
$dst = $base . Vfs :: parse_url ( $src , PHP_URL_PATH );
2013-04-10 18:46:43 +02:00
if ( is_link ( $src ))
{
2016-05-05 09:20:07 +02:00
if (( $target = Vfs\Sqlfs\StreamWrapper :: readlink ( $src )))
2013-04-10 18:46:43 +02:00
{
if ( $target [ 0 ] != '/' )
{
2016-05-05 09:20:07 +02:00
$target = Vfs :: dirname ( $src ) . '/' . $target ;
2013-04-10 18:46:43 +02:00
}
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
{
2016-05-05 09:20:07 +02:00
$target = Vfs\Sqlfs\StreamWrapper :: _fs_path ( $stat [ 'ino' ]);
2013-04-10 18:46:43 +02:00
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
}