view release on metacpan or search on metacpan
lib/File/AtomicWrite.pm view on Meta::CPAN
or croak 'group not in group database';
$gid = $group_gid;
}
}
my $count = chown( $uid, $gid, $filename );
if ( $count != 1 ) {
die "unable to chown temporary file\n";
}
return 1;
}
lib/File/AtomicWrite.pm view on Meta::CPAN
Accepts C<mtime> timestamp for C<utime> to be applied to the file.
Usual throwing of error.
=item B<owner> => I<unix ownership string>
Accepts similar arguments to chown(1) to be applied via C<chown>
to the file. Usual throwing of error.
...->write_file({ ..., owner => '0' });
...->write_file({ ..., owner => '0:0' });
...->write_file({ ..., owner => 'user:somegroup' });
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Copy/Undoable.pm view on Meta::CPAN
return [500, "Can't rsync: ".explain_child_error($?)] if $?;
if (defined($args{target_owner}) || defined($args{target_group})) {
if ($> == 0) {
log_info("Chown-ing $target ...");
@cmd = (
"chown", "-Rh",
join("", $args{target_owner}//"", ":",
$args{target_group}//""),
$target);
system @cmd;
return [500, "Can't chown: ".explain_child_error($?)] if $?;
} else {
log_debug("Not running as root, not doing chown");
}
}
return [200, "OK"];
}
[400, "Invalid -tx_action"];
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Copy/ppport.h view on Meta::CPAN
KEY_chdir|5.003007||Viu
KEY_CHECK|5.006000||Viu
KEY_chmod|5.003007||Viu
KEY_chomp|5.003007||Viu
KEY_chop|5.003007||Viu
KEY_chown|5.003007||Viu
KEY_chr|5.003007||Viu
KEY_chroot|5.003007||Viu
KEY_close|5.003007||Viu
KEY_closedir|5.003007||Viu
KEY_cmp|5.003007||Viu
lib/File/Copy/ppport.h view on Meta::CPAN
PERL_LANGINFO_H|5.027004||Viu
PERL_LAST_5_18_0_INTERP_MEMBER|5.017009||Viu
Perl_ldexp|5.021003|5.021003|n
PerlLIO_access|5.005000||Viu
PerlLIO_chmod|5.005000||Viu
PerlLIO_chown|5.005000||Viu
PerlLIO_chsize|5.005000||Viu
PerlLIO_close|5.005000||Viu
PerlLIO_dup2|5.005000||Viu
PerlLIO_dup2_cloexec|5.027008||Viu
PerlLIO_dup|5.005000||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Create/Layout.pm view on Meta::CPAN
schema => 'str*',
},
},
};
sub create_files_using_layout {
require File::chown;
my %args = @_;
my $parse_res;
eval { $parse_res = _parse_layout($args{layout}) };
lib/File/Create/Layout.pm view on Meta::CPAN
}
if (defined($e->{user}) || defined($e->{group})) {
my %opts;
$opts{deref} = 0 if $e->{is_symlink};
File::chown::chown(\%opts, $e->{user}, $e->{group}, $e->{name})
or return [500, "Can't chown file $p/$e->{name}: $!"];
}
$prev_level = $e->{level};
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/DataClass/IO.pm view on Meta::CPAN
sub chomp {
$_[ 0 ]->_chomp( TRUE ); return $_[ 0 ];
}
sub chown {
my ($self, $uid, $gid) = @_;
(defined $uid and defined $gid)
or $self->$_throw( Unspecified, [ 'user or group id' ] );
1 == CORE::chown $uid, $gid, $self->name
or $self->$_throw( 'Path [_1 chown failed to [_2]/[_3]',
[ $self->name, $uid, $gid ] );
return $self;
}
sub clear {
lib/File/DataClass/IO.pm view on Meta::CPAN
$io = io( 'path_to_file' )->chomp;
Causes input lines to be chomped when L</getline> or L</getlines> are called
=head2 chown
$io = io( 'path_to_file' )->chown( $uid, $gid );
Changes user and group ownership
=head2 clear
view all matches for this distribution
view release on metacpan or search on metacpan
or die "$dst: file size mismatch\n";
close $dst_fh
or $s_skipped++, goto bailout;
chown $uid, $gid, $dst
or $s_skipped++, goto bailout;
chmod $mode, $dst
or $s_skipped++, goto bailout;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/DirSync.pm view on Meta::CPAN
return;
}
# Force permissions to match the source
chmod( $stat_src[2] & 0777, $dst) or warn "$dst: Failed to chmod: $!\n";
# Force user and group ownership to match the source
chown( $stat_src[4], $stat_src[5], $dst) or warn "$dst: Failed to chown: $!\n";
# Force timestamp to match the source.
utime $when_src, $when_src, $dst or warn "$dst: Failed to utime: $!\n";
$self->_op(4) if $self->{_gentle_percent};
return;
}
lib/File/DirSync.pm view on Meta::CPAN
$self->_dirsync("$src/$node", "$dst/$node");
}
# Force permissions to match the source
chmod( $stat_src[2] & 0777, $dst) or warn "$dst: Failed to chmod: $!\n";
# Force user and group ownership to match the source
chown( $stat_src[4], $stat_src[5], $dst) or warn "$dst: Failed to chown: $!\n";
# Force timestamp to match the source.
utime $when_src, $when_src, $dst or warn "$dst: Failed to utime: $!\n";
$self->_op(5) if $self->{_gentle_percent};
return;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Find/ProjectCycleMigration.pm view on Meta::CPAN
print OUTFILE $wholeFileString;
if ( not( close(OUTFILE) ) ) { die("Error closing file: $!"); }
# set the file mode.
chmod( $mode, $currentFile );
chown( $uid, $gid, $currentFile );
open( FILE, ">>$logFile" ) || die "cann't open the $!\n";
print FILE "---------------------------------------------\n";
print FILE "$replaceCount replacements made at\n";
print FILE "$currentFile\n";
view all matches for this distribution
view release on metacpan or search on metacpan
t/_createtestfiles.pl view on Meta::CPAN
die("Can't create $testfiledir/$filename: $!\n");
print FILE $filename;
close(FILE);
if(defined($user) && $> == 0) { # if running as root ...
chmod($mode, "$testfiledir/$filename");
chown($user, $group, "$testfiledir/$filename");
}
}
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Fu/File.pm view on Meta::CPAN
close($ofh) or croak("write '$dest' failed: $!");
# TODO some form of rollback?
# TODO handle opts
#if($opts{preserve}) {
# # TODO chmod/chown and such
# $dest->utime($self->stat->mtime);
#}
return($dest);
} # copy ###############################################################
view all matches for this distribution
view release on metacpan or search on metacpan
KEY_chdir|5.003007||Viu
KEY_CHECK|5.006000||Viu
KEY_chmod|5.003007||Viu
KEY_chomp|5.003007||Viu
KEY_chop|5.003007||Viu
KEY_chown|5.003007||Viu
KEY_chr|5.003007||Viu
KEY_chroot|5.003007||Viu
KEY_close|5.003007||Viu
KEY_closedir|5.003007||Viu
KEY_cmp|5.003007||Viu
PERL_LANGINFO_H|5.027004||Viu
PERL_LAST_5_18_0_INTERP_MEMBER|5.017009||Viu
Perl_ldexp|5.021003|5.021003|n
PerlLIO_access|5.005000||Viu
PerlLIO_chmod|5.005000||Viu
PerlLIO_chown|5.005000||Viu
PerlLIO_chsize|5.005000||Viu
PerlLIO_close|5.005000||Viu
PerlLIO_dup2|5.005000||Viu
PerlLIO_dup2_cloexec|5.027008||Viu
PerlLIO_dup|5.005000||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/KDBX/Dumper.pm view on Meta::CPAN
if ($filepath_temp) {
$mode //= $file_mode // do { my $m = umask; defined $m ? oct(666) &~ $m : undef };
$uid //= $file_uid // -1;
$gid //= $file_gid // -1;
chmod($mode, $filepath_temp) if defined $mode;
chown($uid, $gid, $filepath_temp);
rename($filepath_temp, $filepath) or throw "Failed to write file ($filepath): $!",
filepath => $filepath;
}
return $self;
lib/File/KDBX/Dumper.pm view on Meta::CPAN
C<mode> - File mode / permissions (see L<perlfunc/"chmod LIST">
=item *
C<uid> - User ID (see L<perlfunc/"chown LIST">)
=item *
C<gid> - Group ID (see L<perlfunc/"chown LIST">)
=item *
C<atomic> - Write to the filepath atomically (default: true)
view all matches for this distribution
view release on metacpan or search on metacpan
KEY_chdir|5.003007||Viu
KEY_CHECK|5.006000||Viu
KEY_chmod|5.003007||Viu
KEY_chomp|5.003007||Viu
KEY_chop|5.003007||Viu
KEY_chown|5.003007||Viu
KEY_chr|5.003007||Viu
KEY_chroot|5.003007||Viu
KEY_close|5.003007||Viu
KEY_closedir|5.003007||Viu
KEY_cmp|5.003007||Viu
PERL_LANGINFO_H|5.027004||Viu
PERL_LAST_5_18_0_INTERP_MEMBER|5.017009||Viu
Perl_ldexp|5.021003||Viu
PerlLIO_access|5.005000||Viu
PerlLIO_chmod|5.005000||Viu
PerlLIO_chown|5.005000||Viu
PerlLIO_chsize|5.005000||Viu
PerlLIO_close|5.005000||Viu
PerlLIO_dup2|5.005000||Viu
PerlLIO_dup2_cloexec|5.027008||Viu
PerlLIO_dup|5.005000||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/ppport.h view on Meta::CPAN
KEY_chdir|5.003007||Viu
KEY_CHECK|5.006000||Viu
KEY_chmod|5.003007||Viu
KEY_chomp|5.003007||Viu
KEY_chop|5.003007||Viu
KEY_chown|5.003007||Viu
KEY_chr|5.003007||Viu
KEY_chroot|5.003007||Viu
KEY_close|5.003007||Viu
KEY_closedir|5.003007||Viu
KEY_cmp|5.003007||Viu
lib/File/ppport.h view on Meta::CPAN
PERL_LANGINFO_H|5.027004||Viu
PERL_LAST_5_18_0_INTERP_MEMBER|5.017009||Viu
Perl_ldexp|5.021003|5.021003|n
PerlLIO_access|5.005000||Viu
PerlLIO_chmod|5.005000||Viu
PerlLIO_chown|5.005000||Viu
PerlLIO_chsize|5.005000||Viu
PerlLIO_close|5.005000||Viu
PerlLIO_dup2|5.005000||Viu
PerlLIO_dup2_cloexec|5.027008||Viu
PerlLIO_dup|5.005000||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/NCopy.pm view on Meta::CPAN
utime $atime,$mtime,$file_to
unless ref $file_to eq 'GLOB' || ref $file_to eq 'FileHandle';
# this may only work for men in white hats; on Unix
chown $uid,$gid,$file_to
unless ref $file_to eq 'GLOB' || ref $file_to eq 'FileHandle';
1;
}
# all the actual copying is done here, folks ;)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Ownership/Unix.pm view on Meta::CPAN
my $foo=File::Ownership::Unix->new( 1001, 1001 );
#gets the ownership info for a file
$foo->setFromFile('/tmp/foo');
#chowns a file using the current [GU]ID
$foo->chown('/tmp/bar');
#copies the ownership info from one file to another
$foo->setFromFile('/tmp/foo');
$foo->chown('/tmp/bar');
=head1 METHODS
=head2 new
lib/File/Ownership/Unix.pm view on Meta::CPAN
}
return $self;
}
=head2 chown
This chowns the specified file.
$foo->chown('/tmp/foo');
if( $foo->error ){
warn('error:'.$foo->error.': '.$foo->errorString);
}
=cut
sub chown{
my $self=$_[0];
my $file=$_[1];
$self->errorblank;
if($self->error){
lib/File/Ownership/Unix.pm view on Meta::CPAN
$self->{error}=3;
$self->{errorString}='"'.$file.'" does not exist';
return undef;
}
if(!chown( $self->{uid}, $self->{gid}, $file )){
$self->{error}=4;
$self->{errorString}='Failed to chown "'.$file.'" to "'.$self->{uid}.':'.$self->{gid}.'"';
return undef;
}
return 1;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Path.pm view on Meta::CPAN
);
delete $data->{group};
}
}
if ( exists $data->{owner} and not exists $data->{group} ) {
$data->{group} = -1; # chown will leave group unchanged
}
if ( exists $data->{group} and not exists $data->{owner} ) {
$data->{owner} = -1; # chown will leave owner unchanged
}
}
$paths = [@_];
}
return _mkpath( $data, $paths );
lib/File/Path.pm view on Meta::CPAN
if ( mkdir( $path, $data->{mode} ) ) {
push( @created, $path );
if ( exists $data->{owner} ) {
# NB: $data->{group} guaranteed to be set during initialisation
if ( !chown $data->{owner}, $data->{group}, $path ) {
_error( $data,
"Cannot change ownership of $path to $data->{owner}:$data->{group}"
);
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Prepend/Undoable.pm view on Meta::CPAN
or return [500, "Can't open $path for writing: $!"];
print $nh $string;
while (my $l = <$oh>) { print $nh $l }
close $nh or return [500, "Can't close: $!"];
chmod $st[2] & 07777, $path; # XXX ignore error?
unless ($>) { chown $st[4], $st[5], $path } # XXX ignore error?
return [200, "OK"];
}
[400, "Invalid -tx_action"];
}
view all matches for this distribution
view release on metacpan or search on metacpan
include/ppport.h view on Meta::CPAN
KEY_chdir|5.003007||Viu
KEY_CHECK|5.006000||Viu
KEY_chmod|5.003007||Viu
KEY_chomp|5.003007||Viu
KEY_chop|5.003007||Viu
KEY_chown|5.003007||Viu
KEY_chr|5.003007||Viu
KEY_chroot|5.003007||Viu
KEY_close|5.003007||Viu
KEY_closedir|5.003007||Viu
KEY_cmp|5.003007||Viu
include/ppport.h view on Meta::CPAN
PERL_LANGINFO_H|5.027004||Viu
PERL_LAST_5_18_0_INTERP_MEMBER|5.017009||Viu
Perl_ldexp|5.021003|5.021003|n
PerlLIO_access|5.005000||Viu
PerlLIO_chmod|5.005000||Viu
PerlLIO_chown|5.005000||Viu
PerlLIO_chsize|5.005000||Viu
PerlLIO_close|5.005000||Viu
PerlLIO_dup2|5.005000||Viu
PerlLIO_dup2_cloexec|5.027008||Viu
PerlLIO_dup|5.005000||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
Redirect.xs view on Meta::CPAN
return unix.Open(aTHX_ tab, layers, n, mode, fd, imode, perm, f, narg, args);
}
// #define PerlLIO_chmod(file, mode) \
// (*PL_LIO->pChmod)(PL_LIO, (file), (mode))
// #define PerlLIO_chown(file, owner, group) \
// (*PL_LIO->pChown)(PL_LIO, (file), (owner), (group))
// #define PerlLIO_link(oldname, newname) \
// (*PL_LIO->pLink)(PL_LIO, (oldname), (newname))
// #define PerlLIO_lstat(name, buf) \
// (*PL_LIO->pLstat)(PL_LIO, (name), (buf))
view all matches for this distribution
view release on metacpan or search on metacpan
%RW_HANDLES %RO_HANDLES %RW_TMPFILES %RO_TMPFILES);
use Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(
rreadfile rwritefile rmkdir rrmdir rrm runlink rcp rcopy rtouch rchown
rchmod rmove rmv rbackup setrsh setrcp settmp ropen rclose rappend rprepend
rsymlink rlink readfile writefile mkdir rmdir rm unlink cp copy touch chown
chmod move mv backup open close append prepend symlink link readlink rreadlink
);
%EXPORT_TAGS = (
files => [qw(ropen rclose rreadfile rwritefile runlink rcopy rtouch rmove
rbackup rappend rprepend rlink rsymlink rreadlink)],
config => [qw(setrsh setrcp settmp)],
dirs => [qw(rmkdir rrmdir)],
perms => [qw(rchown rchmod)],
standard => [qw(ropen rclose rreadfile rwritefile runlink rcopy rtouch rmove
rbackup rappend rprepend setrsh setrcp settmp rmkdir rrmdir
rchown rchmod rsymlink rlink rreadlink)],
aliases => [qw(rrm rmv rcp)],
replace => [qw(open close readfile writefile unlink rm copy cp touch move mv
backup append prepend setrsh setrcp settmp mkdir rmdir chown chmod
symlink link readlink)]
);
# Straight from CPAN
$VERSION = do { my @r=(q$Revision: 1.17 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
(©(@_) && &unlink(@_)) || return undef;
return 1;
}
#######
# Usage: $remote->chown($file1, $file2);
#
# This chown's files just like UNIX chown.
#######
*rchown = \&chown;
sub chown {
# If remote, subshell it; else, use Perl's chown
# Form of chown is the same as normal chown
my($self, $uid, $gid, $file) = _self_or_default(@_);
croak "Bad usage of chown" unless ($uid && $gid && $file);
my($rhost, $lfile) = _parsepath($file);
if($rhost) {
$self->_system($self->setrsh, $rhost, "'chown $uid $lfile ; chgrp $gid $lfile'") or return undef;
} else {
# Check if we need to resolve stuff
($uid) = getpwnam($uid) if ($uid =~ /[a-zA-Z]/);
($gid) = getgrnam($gid) if ($gid =~ /[a-zA-Z]/);
chown($uid, $gid, $lfile) || return undef;
}
return 1;
}
#######
#######
*rchmod = \&chmod;
sub chmod {
# Same as chown, really easy
my($self, $mode, $file) = _self_or_default(@_);
croak "Bad usage of chmod" unless ($mode && $file);
my($rhost, $lfile) = _parsepath($file);
if($rhost) {
mkdir("host:/remote/dir", 0755);
unlink("host:/remote/file");
unlink("/local/file"); # still works too!
symlink("host:/remote/src", "host:/remote/dest");
chown("root", "other", "host:/remote/dir/file");
chmod(0600, "host:/remote/dir/file");
#
# Next, the object-oriented style, if you don't want to
# mess with the builtins.
print FILE "Hello, world!\n";
close(FILE) or die "Close failed: $!\n";
mkdir("/local/new/dir", "2775");
mkdir("host:/remote/new/dir");
chown("root", "other", "/local/new/dir");
unlink("host:/remote/file");
This is pretty neat; since C<File::Remote> will pass calls to local files
straight through to Perl's core functions, you'll be able to do all this
"transparently" and not care about the locations of the files. Plus,
=head2 move(file1, file2)
Moves a file ala File::Copy. You can also address it as 'mv'
(if you import the :aliases tag).
=head2 chmod(mode, file) ; chown(owner, group, file)
Change the permissions or the owner of a file.
=head2 unlink(file)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Rotate/Backup/Copy.pm view on Meta::CPAN
$atime,$mtime,$ctime,$blksize,$blocks)
= stat(_);
my $permissions = $mode & 07777;
chown $uid, $gid, $dst_file;
chmod $permissions, $dst_file;
utime $atime, $mtime, $dst_file;
}
sub _copyPlainFile {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/Rotate/Simple.pm view on Meta::CPAN
$current->move($rotated);
}
$self->file->touch if $self->touch;
# TODO: chmod/chown arguments
}
sub _build_files_to_rotate {
my ($self) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
},
# these have simple scalar args we cannot easily check
# use 'string' so I don't forget and leave keyword scalar unqouted
string => {
map { $_ => '' }
qw(address backup-dir block-size bwlimit checksum-seed chown
compress-level config contimeout csum-length debug files-from
groupmap iconv info log-file log-file-format log-format max-delete
max-size min-size modify-window only-write-batch out-format outbuf
partial-dir password-file port protocol read-batch rsh rsync-path
skip-compress sockopts suffix temp-dir timeout usermap
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/RsyncP/FileIO.pm view on Meta::CPAN
&& !chmod($f->{mode} & ~S_IFMT, $lName) ) {
$fio->log(sprintf("Can't chmod(%s, 0%o)", $lName, $f->{mode}));
$ret = -1;
}
if ( ($f->{uid} != $a->{uid} || $f->{gid} != $a->{gid})
&& !chown($f->{uid}, $f->{gid}, $lName) ) {
$fio->log("Can't chown($f->{uid}, $f->{gid}, $lName)");
$ret = -1;
}
if ( ($f->{mtime} != $a->{mtime} || $f->{atime} != $a->{atime})
&& !utime($f->{atime}, $f->{mtime}, $lName) ) {
$fio->log("Can't mtime($f->{atime}, $f->{mtime}, $lName)");
view all matches for this distribution
view release on metacpan or search on metacpan
examples/procmail/scanvirus.pl view on Meta::CPAN
close(MAILBOX);
close(MSG);
chmod(0600, $mailbox);
my ($uid, $gid) = (getpwnam($user))[2,3];
chown($uid, $gid, $mailbox) if($uid && $gid);
return();
}
#---clean_dir-------------------------------------------------------------
view all matches for this distribution
view release on metacpan or search on metacpan
KEY_chdir|5.003007||Viu
KEY_CHECK|5.006000||Viu
KEY_chmod|5.003007||Viu
KEY_chomp|5.003007||Viu
KEY_chop|5.003007||Viu
KEY_chown|5.003007||Viu
KEY_chr|5.003007||Viu
KEY_chroot|5.003007||Viu
KEY_close|5.003007||Viu
KEY_closedir|5.003007||Viu
KEY_cmp|5.003007||Viu
PERL_LANGINFO_H|5.027004||Viu
PERL_LAST_5_18_0_INTERP_MEMBER|5.017009||Viu
Perl_ldexp|5.021003|5.021003|n
PerlLIO_access|5.005000||Viu
PerlLIO_chmod|5.005000||Viu
PerlLIO_chown|5.005000||Viu
PerlLIO_chsize|5.005000||Viu
PerlLIO_close|5.005000||Viu
PerlLIO_dup2|5.005000||Viu
PerlLIO_dup2_cloexec|5.027008||Viu
PerlLIO_dup|5.005000||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
lib/File/System/Real.pm view on Meta::CPAN
/^mode$/ && do {
chmod $value, $self->{fullpath};
last SWITCH;
};
/^uid$/ && do {
chown $value, $self->get_property('gid'), $self->{fullpath};
last SWITCH;
};
/^gid$/ && do {
chown $self->get_property('uid'), $value, $self->{fullpath};
last SWITCH;
};
/^atime$/ && do {
utime $value, $self->get_property('mtime'), $self->{fullpath};
last SWITCH;
view all matches for this distribution
view release on metacpan or search on metacpan
init.d/tail_to_scribe view on Meta::CPAN
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
if [ ! -d $STATEDIR ]; then
mkdir -p $STATEDIR
fi
chown -R $RUNASUSER $STATEDIR
USERDIR=`eval echo ~$RUNASUSER`
[ -d $USERDIR ] || mkdir -p $USERDIR
RETVAL=0
view all matches for this distribution