- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
$ chmod article 666
FIRST!
Admin
Too simple. My method of checking file permissions would have many more steps, and involve a wooden table.
Admin
No... chmod article 777
I want to be able to execute the code in it too!
Admin
Gloves!
Admin
regex rulez not
Admin
Pretty sure those are backwards - the 256 is owner read and the 4 is other read (since mode 0600 is read/write only for the owner, not other users).
Admin
This reminds me of the following xkcd comic:
http://xkcd.com/208/
Stand Back! I know regular expressions!
Admin
Heh...heh...it says "$perms".
Admin
OK, this has to be approaching the record for number of WTFs per byte of code!
We'll just start here:
$perms->mode & 0777
Whoever wrote this had some clue about masking bits in/out of the permissions result. So close, yet so far...
Admin
http://de2.php.net/manual/en/function.posix-access.php
Admin
Stupid question, what's a clean way to do it?
Admin
if(-r $path){
file is readable
}
Admin
You missed the (.).(.) part
Admin
Pretty clever though.
Admin
What exactly is a $permsbin? This code kinda makes me wanna go home to my wife and $earch for one...
Admin
Actually, it contained (.)..(.)..(.) Clearly a reference to Eccentrica Gallumbits, the triple-breasted whore of Eroticon Six
Admin
LOL
Admin
The RWTF is the
.Admin
If you think you are going to need PERL, then it's probably too late to save you. You shall die a painful regexp death.
Admin
As someone mentioned, perl has inherited test(1)'s -r test for checking if a file is readable, and that aside stat(2) is only a partial check - it'll tell you the unix permissions, but not quite which apply to you, nor if there are ACLs involved. Most of the time you don't need to check, and if you do, chances are you want access(2). Perl's equivalent difference is in -r versus -R.
Admin
Who's buying my $permsbin?
Admin
Hah! lol!
Admin
~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o O ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o ~~o
Admin
stat($path) should be (stat($path))[2]
Even Rube Goldberg machines should work.
Admin
Admin
Failure for forgetting to include "-R" somewhere, and preferably a "/", too.
Admin
Admin
chmod 666 /bin/chmod :)
Admin
And all go into the $permsbin
Admin
chmod 777 article
Admin
Is that a problem? If you are a superuser, Instead of running dubious built-in shell command search for the source code of 'chmod'. When all else fails backup your files, format the disk, and write a program in assembly language to change the permissions of a file. If you cannot trust your assembler write the generated machine code, and write it to the computer's memory.
Admin
The new Ovula Invaders!
Admin
Could someone tell me why you want to know if a file is universally readable? I mean I could see wanting to know if some user X can read a file (if he is user/group/other to the file), but I have never written something to ensure that ugo+r was set.
Admin
EAFP anyway.
Admin
Ah, I fondly remember Eroticon Six. But, Comic-con XII was much better. There was this woman in a Xena costume...
Admin
Which is why you use
S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU S_ISGID S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR
if you are even going to go the route of doing this yourself and not letting perl shortcut it for you. C provides these in stat.h, and perl provides them as part of the POSIX module.
Admin
plz, send teh codes.
Admin
You have nothing to teach to Bill Gates about UNIX. You were either still a naughty project from your parent or at most very young when Microsoft worked on XENIX.
A lot of things happened in the past. I guess you should learn about people before you bash them.
Admin
..and of course there's...
I won't go into the mechanics of backtracking etc., but that expression could conceivably take many many millions of years to run...
Admin
got 200 problems but a b1tch ain't one
Admin
That's because it's actually not UNIX.
Admin
This is a UNIX system. I know this!
Admin
Yeah, he was still a $perm at that time.
Admin
Here's the correct way to do it.
Admin
And? Never heard of self-propagating code?
:-)
Admin
so that's more like two-hundred-million little problems
Admin
So much for my mode-700 files.
rwx------
Admin
Ah, Perl. The Swiss Army Chainsaw.
Admin
Admin