Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] test for *other* write permissions



Derek Martin wrote:
> I'd use Python or C (or <shudder> Perl for this).
> 
>>>> import stat, os
>>>> mode = os.stat(".bashrc")
>>>> print ((mode.st_mode | stat.S_IWGRP) and mode.st_gid == 0)
> False

Shudder yourself. This operation is perfectly legible in Perl:

use File::stat;
use Fcntl qw(S_IWGRP S_IWOTH); # import fcntl.h symbols
my $fs = stat($filename);
print "$filename is group or other writable\n"
  if $fs && $fs->mode & (S_IWGRP | S_IWOTH);

(Are you sure your code tests that the file is group or other writable?
You seem to be only testing for group write and that the group owner is
root.)

 -Tom

-- 
Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile: http://tmetro.venturelogic.com/



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org