Hello, I have a perl script that runs in a Linux system, it basically reads a list of files and attributes and copies them to the right directory and set the attributes accordingly.
The script works fine with files with "regular" attributes like 0755, I'm doing something like this:
copy($filezip, $filetarget) or die "File cannot be copied.";
chmod oct($fileperms),$filetarget or die "Perms not changed.";
chown $uid, $gid, $filetarget;
But when the file has attributes that set the suid permissions (4755) the target file is not set with these attributes.
I tried running chmod from a system call and it didn't work:
system("/bin/chmod $fileperms $filetarget");
I tried using a umask as follows and it didn't work either:
my $perms = ((stat($filezip))[2] & 07777);
my $newperms = $perms ^ 04000;
chmod $newperms, $filetarget or die "Perms not changed.";
Does anyone knows how to set the suid permission from a perl script?
Thanks
The script works fine with files with "regular" attributes like 0755, I'm doing something like this:
copy($filezip, $filetarget) or die "File cannot be copied.";
chmod oct($fileperms),$filetarget or die "Perms not changed.";
chown $uid, $gid, $filetarget;
But when the file has attributes that set the suid permissions (4755) the target file is not set with these attributes.
I tried running chmod from a system call and it didn't work:
system("/bin/chmod $fileperms $filetarget");
I tried using a umask as follows and it didn't work either:
my $perms = ((stat($filezip))[2] & 07777);
my $newperms = $perms ^ 04000;
chmod $newperms, $filetarget or die "Perms not changed.";
Does anyone knows how to set the suid permission from a perl script?
Thanks