2007-05-29 10:35:27 +02:00
#!/usr/bin/php -qC
< ? php
/**
2008-01-29 08:24:16 +01:00
* Filemanager - Command line interface : ls
2007-05-29 10:35:27 +02:00
*
* @ link http :// www . egroupware . org
* @ package admin
* @ author Ralf Becker < RalfBecker - AT - outdoor - training . de >
* @ copyright ( c ) 2006 by Ralf Becker < RalfBecker - AT - outdoor - training . de >
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
* @ version $Id $
*/
chdir ( dirname ( __FILE__ )); // to enable our relative pathes to work
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
error_reporting ( error_reporting () & ~ E_NOTICE );
2008-01-29 08:24:16 +01:00
if ( isset ( $_SERVER [ 'HTTP_HOST' ])) // security precaution: forbit calling ls 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' ]
2007-05-29 10:35:27 +02:00
*
* @ param array & $account account_info with keys 'login' , 'passwd' and optional 'passwd_type'
* @ return boolean / string true if we allow the access and account is set , a sessionid or false otherwise
*/
function user_pass_from_argv ( & $account )
{
$account = $GLOBALS [ 'egw_login_data' ];
//print_r($account);
if ( ! ( $sessionid = $GLOBALS [ 'egw' ] -> session -> create ( $account )))
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
echo " Wrong user-account or -password !!! \n \n " ;
2007-05-29 10:35:27 +02:00
usage ( '' , 1 );
}
return $sessionid ;
}
/**
* Give a usage message and exit
*
* @ param string $action = null
* @ param int $ret = 0 exit - code
*/
function usage ( $action = null , $ret = 0 )
{
2008-01-29 08:24:16 +01:00
$cmd = basename ( __FILE__ );
2008-02-29 08:29:19 +01:00
echo " Usage: \t $cmd ls [-r|--recursive] URL [URL2 ...] \n " ;
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 " ;
echo " \t $cmd chmod [-r|--recursive] mode=[ugoa]*[+-=][rwx]+,... URL [URL2 ...] \n " ;
echo " \t $cmd chown [-r|--recursive] user URL [URL2 ...] \n " ;
echo " \t $cmd chgrp [-r|--recursive] group URL [URL2 ...] \n " ;
2008-03-02 22:44:15 +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) \n " ;
2008-02-29 08:29:19 +01:00
echo " \t $cmd mount URL [path] (without path prints out the mounts) \n " ;
echo " \t $cmd umount URL|path \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 URL: { vfs|sqlfs|oldvfs}://user:password@domain/home/user/file, /dir/file, ... \n " ;
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 " ;
2007-05-29 10:35:27 +02:00
exit ;
}
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
$long = $numeric = $recursive = $perms = false ;
2008-01-29 08:24:16 +01:00
$argv = $_SERVER [ 'argv' ];
$cmd = basename ( array_shift ( $argv ), '.php' );
2008-02-29 08:29:19 +01:00
if ( $argv [ 0 ][ 0 ] != '-' && $argv [ 0 ][ 0 ] != '/' && strpos ( $argv [ 0 ], '://' ) === false )
{
$cmd = array_shift ( $argv );
}
2008-01-29 08:24:16 +01:00
if ( ! $argv ) $argv = array ( '-h' );
2008-02-29 08:29:19 +01:00
$args = $find_options = array ();
while ( ! is_null ( $option = array_shift ( $argv )))
2007-05-29 10:35:27 +02:00
{
2008-02-29 08:29:19 +01:00
if ( $option [ 0 ] != '-' ) // no option --> argument
{
$args [] = $option ;
continue ;
}
2008-01-29 08:24:16 +01:00
switch ( $option )
2007-05-29 10:35:27 +02:00
{
2008-01-29 08:24:16 +01:00
default :
2008-02-29 08:29:19 +01:00
if ( $cmd == 'find' )
{
2008-03-02 22:44:15 +01:00
if ( ! in_array ( $option , array ( '-type' , '-depth' , '-mindepth' , '-maxdepth' , '-name' , '-path' ,
2008-02-29 08:29:19 +01:00
'-uid' , '-user' , '-nouser' , '-gid' , '-group' , '-nogroup' , '-mime' ,
'-empty' , '-size' , '-cmin' , '-ctime' , '-mmin' , '-mtime' )))
{
usage ();
}
2008-03-02 22:44:15 +01:00
if ( in_array ( $option , array ( '-empty' , '-depth' , '-nouser' , '-nogroup' )))
2008-02-29 08:29:19 +01:00
{
$find_options [ substr ( $option , 1 )] = true ;
}
else
{
$find_options [ substr ( $option , 1 )] = array_shift ( $argv );
}
break ;
}
// multiple options, eg. -rp --> -r -p
elseif ( $option [ 0 ] == '-' && $option [ 1 ] != '-' && strlen ( $option ) > 2 )
{
for ( $i = 1 ; $i < strlen ( $option ); ++ $i )
{
array_unshift ( $argv , '-' . $option [ $i ]);
}
break ;
}
2008-01-29 08:24:16 +01:00
case '-h' : case '--help' :
usage ();
case '-l' : case '--long' :
$long = true ;
2008-02-29 08:29:19 +01:00
break ;
2008-01-29 08:24:16 +01:00
case '-n' : case '--numeric' :
$numeric = true ;
2008-02-29 08:29:19 +01:00
break ;
2008-01-29 08:24:16 +01:00
2008-01-30 07:47:53 +01:00
case '-r' : case '--recursive' :
$recursive = true ;
2008-02-29 08:29:19 +01:00
break ;
2008-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
case '-p' : case '--parents' : case '--perms' :
if ( $cmd == 'cp' )
{
$perms = true ;
}
else
{
$recursive = true ;
}
2008-02-29 08:29:19 +01:00
break ;
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
2008-01-30 07:47:53 +01:00
case '-d' : case '--date' :
2008-02-29 08:29:19 +01:00
$time = strtotime ( array_shift ( $argv ));
2008-01-30 07:47:53 +01:00
break ;
2007-05-29 10:35:27 +02:00
}
2008-01-29 08:24:16 +01:00
}
2008-02-29 08:29:19 +01:00
$argv = $args ;
2008-01-29 08:24:16 +01:00
$argc = count ( $argv );
switch ( $cmd )
{
2008-02-29 08:29:19 +01:00
case 'mount' :
if ( $argc > 2 )
{
usage ();
}
load_wrapper ( $url = $argv [ 0 ]);
$fstab = egw_vfs :: mount ( $url , $path = $argv [ 1 ]);
if ( is_array ( $fstab ))
{
foreach ( $fstab as $path => $url )
{
echo " $url\t $path\n " ;
}
}
elseif ( $fstab === false )
{
echo " URL ' $url ' not found! \n " ;
}
else
{
echo " $url successful mounted to $path\n " ;
}
break ;
case 'umount' :
if ( $argc != 1 )
{
usage ();
}
egw_vfs :: umount ( $argv [ 0 ]);
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 '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 ;
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-01-30 07:47:53 +01:00
case 'rename' :
if ( count ( $argv ) != 2 ) usage ( null , 3 );
load_wrapper ( $argv [ 0 ]);
load_wrapper ( $argv [ 1 ]);
rename ( $argv [ 0 ], $argv [ 1 ]);
break ;
2008-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 );
//echo "$cmd $url (long=".(int)$long.", numeric=".(int)$numeric.")\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' :
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( $recursive && class_exists ( 'egw_vfs' ))
{
array_unshift ( $argv , $url );
egw_vfs :: remove ( $argv );
$argv = array ();
}
else
{
unlink ( $url );
}
2008-01-30 07:47:53 +01:00
break ;
case 'rmdir' :
rmdir ( $url );
break ;
case 'mkdir' :
mkdir ( $url , null , $recursive );
break ;
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 )
{
case 'touch' :
$params = array ( $url , $time );
break ;
case 'chmod' :
if ( ! isset ( $mode ))
{
$mode = $url ; // first param is mode
$url = array_shift ( $argv );
}
if ( parse_url ( $url , PHP_URL_SCHEME )) load_wrapper ( $url ); // cant use stat or egw_vfs::mode2int otherwise!
if ( strpos ( $mode , '+' ) !== false || strpos ( $mode , '-' ) !== false )
{
$stat = stat ( $url );
$set = $stat [ 'mode' ];
}
else
{
$set = 0 ;
}
if ( ! class_exists ( 'egw_vfs' ))
{
die ( " chmod only implemented for eGW streams! " ); // dont want to repeat the code here
}
$set = egw_vfs :: mode2int ( $mode , $set );
$params = array ( $url , $set );
break ;
case 'chown' :
case 'chgrp' :
$type = $cmd == 'chgrp' ? 'group' : 'user' ;
if ( ! isset ( $owner ))
{
$owner = $url ; // first param is owner/group
$url = array_shift ( $argv );
if ( parse_url ( $url , PHP_URL_SCHEME )) load_wrapper ( $url ); // we need the header loaded
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! " );
}
if ( ! ( $owner = $GLOBALS [ 'egw' ] -> accounts -> name2id ( $owner_was = $owner , 'account_lid' , $type [ 0 ])) ||
( $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 ;
}
2008-01-30 07:47:53 +01:00
if (( $scheme = 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 );
if ( class_exists ( $class = $scheme . '_stream_wrapper' ) && method_exists ( $class , '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
$cmd = array ( $scheme . '_stream_wrapper' , $cmd );
2008-01-30 07:47:53 +01:00
}
else
{
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 $cmd for scheme $scheme ! \n " );
2008-01-30 07:47:53 +01:00
}
2008-01-29 08:24:16 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( $recursive && class_exists ( 'egw_vfs' ))
2008-01-30 07:47:53 +01:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
array_unshift ( $argv , $url );
$params = array ( $argv , null , $cmd , $params [ 1 ]);
$cmd = array ( 'egw_vfs' , 'find' );
$argv = array (); // we processed all url's
2008-01-30 07:47:53 +01:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
//echo "calling cmd=".print_r($cmd,true).", params=".print_r($params,true)."\n";
call_user_func_array ( $cmd , $params );
2008-01-30 07:47:53 +01:00
break ;
case 'cat' :
case 'ls' :
default :
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
// recursive ls atm only for vfs://
if ( $cmd != 'cat' && $recursive && class_exists ( 'egw_vfs' ))
{
load_wrapper ( $url );
array_unshift ( $argv , $url );
2008-03-02 22:44:15 +01:00
egw_vfs :: find ( $argv , array ( 'url' => true ,), 'do_stat' , array ( $long , $numeric , 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 ();
}
elseif ( is_dir ( $url ) && ( $dir = opendir ( $url )))
2008-01-30 07:47:53 +01:00
{
if ( $argc )
{
2008-02-29 08:29:19 +01:00
if ( ! ( $name = basename ( parse_url ( $url , PHP_URL_PATH )))) $name = '/' ;
echo " \n $name : \n " ;
}
if ( substr ( $url , - 1 ) == '/' )
{
$url = substr ( $url , 0 , - 1 );
2008-01-30 07:47:53 +01:00
}
while (( $file = readdir ( $dir )) !== false )
{
do_stat ( $url . '/' . $file , $long , $numeric );
}
closedir ( $dir );
}
elseif ( $cmd == 'cat' )
{
if ( ! ( $f = fopen ( $url , 'r' )))
{
echo " File $url not found !!! \n \n " ;
}
else
{
if ( $argc )
{
echo " \n " . basename ( parse_url ( $url , PHP_URL_PATH )) . " : \n " ;
}
fpassthru ( $f );
fclose ( $f );
}
}
else
{
do_stat ( $url , $long , $numeric );
}
if ( ! $long && $cmd == 'ls' ) echo " \n " ;
break ;
2008-01-29 08:24:16 +01:00
}
}
}
/**
* Load the necessary wrapper for an url
*
* @ param string $url
*/
function load_wrapper ( $url )
{
2008-01-30 07:47:53 +01:00
switch ( $scheme = parse_url ( $url , PHP_URL_SCHEME ))
2007-05-29 10:35:27 +02:00
{
case 'webdav' :
require_once ( 'HTTP/WebDAV/Client.php' );
break ;
case 'oldvfs' :
2008-01-30 07:47:53 +01:00
case 'vfs' :
2008-02-18 07:51:35 +01:00
case 'sqlfs' :
2007-05-29 10:35:27 +02:00
if ( ! isset ( $GLOBALS [ 'egw_info' ]))
{
$_GET [ 'domain' ] = parse_url ( $url , PHP_URL_HOST );
$GLOBALS [ 'egw_login_data' ] = array (
'login' => parse_url ( $url , PHP_URL_USER ),
'passwd' => parse_url ( $url , PHP_URL_PASS ),
'passwd_type' => 'text' ,
);
if ( is_dir ( '/tmp' )) ini_set ( 'session.save_path' , '/tmp' ); // regular users may have no rights to apache's session dir
$GLOBALS [ 'egw_info' ] = array (
'flags' => array (
2008-01-29 08:24:16 +01:00
'currentapp' => 'filemanager' ,
2007-05-29 10:35:27 +02:00
'noheader' => true ,
'autocreate_session_callback' => 'user_pass_from_argv' ,
)
);
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 ( substr ( $GLOBALS [ 'egw_login_data' ][ 'login' ], 0 , 5 ) != 'root_' )
{
include ( '../header.inc.php' );
}
else
{
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ] = 'login' ;
include ( '../header.inc.php' );
if ( $GLOBALS [ 'egw_login_data' ][ 'login' ] == 'root_' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'header_admin_user' ] &&
_check_pw ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'header_admin_password' ], $GLOBALS [ 'egw_login_data' ][ 'passwd' ]) ||
$GLOBALS [ 'egw_login_data' ][ 'login' ] == 'root_' . $GLOBALS [ 'egw_domain' ][ $_GET [ 'domain' ]][ 'config_user' ] &&
_check_pw ( $GLOBALS [ 'egw_domain' ][ $_GET [ 'domain' ]][ 'config_passwd' ], $GLOBALS [ 'egw_login_data' ][ 'passwd' ]))
{
echo " \n Root access granted! \n " ;
egw_vfs :: $is_root = true ;
}
else
{
die ( " Unknown user or password! \n " );
}
set_exception_handler ( 'cli_exception_handler' ); // otherwise we get html!
}
2008-03-02 22:44:15 +01:00
$cmd = $GLOBALS [ 'cmd' ];
if ( ! in_array ( $cmd , array ( 'ls' , 'find' , 'mount' , 'umount' )) && $GLOBALS [ 'egw_info' ][ 'server' ][ 'files_dir' ] && ! is_writable ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'files_dir' ]))
{
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 " ;
}
2007-05-29 10:35:27 +02:00
}
2008-01-30 07:47:53 +01:00
require_once ( EGW_API_INC . '/class.' . $scheme . '_stream_wrapper.inc.php' );
2007-05-29 10:35:27 +02:00
break ;
2008-01-30 07:47:53 +01:00
case '' : // default scheme is file and alsways available
2007-05-29 10:35:27 +02:00
break ;
default :
2008-01-30 07:47:53 +01:00
if ( ! in_array ( $scheme , stream_get_wrappers ()))
{
die ( " Unknown scheme ' $scheme ' in $url !!! \n \n " );
}
break ;
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
/**
* Check password against a md5 hash or cleartext password
*
* @ param string $hash_or_cleartext
* @ param string $pw
* @ return boolean
*/
function _check_pw ( $hash_or_cleartext , $pw )
{
//echo "_check_pw($hash_or_cleartext,$pw) md5=".md5($pw)."\n";
if ( preg_match ( '/^[0-9a-f]{32}$/' , $hash_or_cleartext ))
{
return $hash_or_cleartext == md5 ( $pw );
}
return $hash_or_cleartext == $pw ;
}
2008-01-29 08:24:16 +01:00
/**
* Give the stats for one file
*
* @ param string $url
* @ param boolean $long = false true = long listing with owner , group , size , perms , default false only filename
* @ param boolean $numeric = false true = give numeric uid & gid , else resolve the id to a name
*/
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_stat ( $url , $long = false , $numeric = false , $full_path = 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";
$bname = parse_url ( $url , PHP_URL_PATH );
if ( ! $full_path )
{
$bname = basename ( $bname );
}
2008-01-30 07:47:53 +01:00
if ( $long && ( $stat = stat ( $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
//echo $url; print_r($stat);
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 ( class_exists ( 'egw_vfs' ))
{
$perms = egw_vfs :: int2mode ( $stat [ 'mode' ]);
}
else
{
$perms = int2mode ( $stat [ 'mode' ]);
}
2008-01-29 08:24:16 +01:00
if ( $numeric )
{
$uid = $stat [ 'uid' ];
$gid = $stat [ 'gid' ];
}
else
{
if ( $stat [ 'uid' ])
{
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
$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' ])
{
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
$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' ];
echo " $perms $nlink\t $uid\t $gid\t $size\t $mtime\t $bname\n " ;
}
else
{
echo " $bname\t " ;
}
}
function hsize ( $size )
{
if ( $size < 1024 ) return $size ;
if ( $size < 1024 * 1024 ) return sprintf ( '%3.1lfk' ,( float ) $size / 1024 );
return sprintf ( '%3.1lfM' ,( float ) $size / ( 1024 * 1024 ));
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
function do_cp ( $argv , $recursive = false , $perms = false )
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
$to = array_pop ( $argv );
load_wrapper ( $to );
$to_exists = file_exists ( $to );
if ( count ( $argv ) > 1 && $to_exists && ! is_dir ( $to ))
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
usage ( null , 4 );
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
foreach ( $argv as $from )
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
if ( is_dir ( $from ) && ( ! file_exists ( $to ) || is_dir ( $to )) && $recursive && class_exists ( 'egw_vfs' ))
{
2008-03-02 22:44:15 +01:00
foreach ( egw_vfs :: find ( $from , array ( 'url' => true )) as $f )
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
{
$t = $to . substr ( $f , strlen ( $from ));
if ( is_dir ( $f ))
{
++ $anz_dirs ;
mkdir ( $t );
}
else
{
++ $anz_files ;
_cp ( $f , $t );
}
if ( $perms ) _cp_perms ( $f , $t );
}
echo ( $anz_dirs ? " $anz_dirs dir(s) created and " : '' ) . " $anz_files file(s) copied. \n " ;
}
else
{
_cp ( $from , $to , true );
if ( $perms ) _cp_perms ( $from , $to );
}
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
}
function _cp ( $from , $to , $verbose = false , $perms = false )
{
load_wrapper ( $from );
if ( is_dir ( $to ) || ! file_exists ( $to ) && is_dir ( $from ) && $mkdir )
2007-05-29 10:35:27 +02:00
{
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
$path = parse_url ( $from , PHP_URL_PATH );
if ( is_dir ( $to )) $to .= '/' . basename ( $path );
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
}
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 );
if ( $verbose ) echo hsize ( $count ) . " bytes written to $to\n " ;
fclose ( $from_fp );
if ( ! fclose ( $to_fp ))
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
die ( " Error closing $to ! \n " );
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
}
function _cp_perms ( $from , $to )
{
if (( $from_stat = stat ( $from )) && ( $to_stat = stat ( $to )))
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
foreach ( array (
'mode' => 'chmod' ,
'uid' => 'chown' ,
'gid' => 'chgrp' ,
) as $perm => $cmd )
{
if ( $from_stat [ $perm ] != $to_stat [ $perm ])
{
//echo "egw_vfs::$cmd($to,{$from_stat[$perm]}\n";
call_user_func ( array ( 'egw_vfs' , $cmd ), $to , $from_stat [ $perm ]);
}
}
2007-05-29 10:35:27 +02:00
}
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
}
2008-02-29 08:29:19 +01:00
function do_find ( $bases , $options )
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
{
foreach ( $bases as $url )
2007-05-29 10:35:27 +02:00
{
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
load_wrapper ( $url );
2007-05-29 10:35:27 +02:00
}
2008-03-02 22:44:15 +01:00
$options [ 'url' ] = true ; // we use url's not vfs pathes in filemanager/cli.php
2008-02-29 08:29:19 +01:00
foreach ( egw_vfs :: find ( $bases , $options ) as $path )
More improvments of the sqlfs code and the command line interface:
- read rights are not checks in each traversed directory (via sql in a single query to locate the path)
- diropen additionally checks for execute rights
- fopen checks for read or write depending on the mode
- chmod, chgrp, chown methods in sqlfs and egw_vfs/vfs plus an egw_vfs::$is_root var used to grant root rights (no access controll and chown or chgrp without being the owner of a file)
- find method (some more params to come) to recursivly search and optionaly execute some callback
- egw_vfs::remove doing a "rm -r" / recursive remove or dirs and files
- new files or dirs inherit the perms and ownership from the parent directory (no umask)
- files/dirs the user has no read rights, in a directory where he has no write rights, get hidden (eg. not showing all the other users / groups home dirs
- many new cli commands (chmod, chgrp, chown, find), recursive option for most commands and the ability to use it with root rights, see the usage message if called without options
- "cp -r -p" to copy a whole tree incl. ownership and perms, eg. backing up /home to /backup
2008-02-26 09:51:42 +01:00
{
echo " $path\n " ;
}
}
2007-05-29 10:35:27 +02:00
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 cli_exception_handler ( Exception $e )
{
echo $e -> getMessage () . " \n " ;
exit ( $e -> getCode ());
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
/**
* 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
{
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 ( $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
elseif ( $mode & 0xA000 ) // Symbolic Link
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 = 'l' ;
}
elseif ( $mode & 0xC000 ) // Socket
{
$sP = 's' ;
}
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
}