Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Loonix halp

Name: Anonymous 2008-01-22 18:24

How would I make my program check if it was root?

Name: Anonymous 2008-01-22 18:27

Read SICP

Name: Anonymous 2008-01-22 18:31

Use xmonad.

Name: Anonymous 2008-01-22 18:33

#include <pwd.h>

Name: Anonymous 2008-01-22 18:43

my $username = getpwuid($<);
print "not " x ($username ne 'root'), "running as root\n";

Name: Anonymous 2008-01-22 18:43

This is in C, guise.

Name: Anonymous 2008-01-22 18:53


#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>

int main () {
    if ( geteuid() == 0 )
        printf("You're root!\n");
    else
        printf("You're lower than a maggot!\n");
    return 0;
}


Also, `man 2 geteuid'.

Name: Anonymous 2008-01-22 19:07

>>4

extern struct passwd *getpwent (void);

I didn't know there was a standard function to automate what I always do manually in multiplayer FPSen. You really do learn something new every day. Thanks!

Name: Anonymous 2008-01-22 19:20

>>1
((lambda (f) (f f)) (lambda (f) (f f)))

Name: Anonymous 2008-01-22 19:39

>>9
Read SICP.

Name: Anonymous 2008-01-22 20:02


#include <stdio.h>
#include <stdlib.h>

int main(void) {

    if(strcmp("root", getenv("USER")) == 0)
        printf("you are root\n");
    else printf("you are not root\n");

    return 0;
}

Name: Anonymous 2008-01-22 20:28

>>11
Wrong, wrong, wrong. The user could easily `export USER=root' and, if the rest of the program is just as stupid, possibly cause some sort of security breach. It would also break with `su -p', `sudo' (with some sort of moronic configuration that keeps the value of $USER), or any number of programs that call `seteuid()' without updating the environment.

Name: Anonymous 2008-01-22 20:35

>>7
wrong. >>1 didn't say uid 0, he said root.

>>11
wrong.
$ env USER=root ./\>\>10\'s\ shitty\ program
you are root
$

OH SHI-

#include <pwd.h>
#include <stdio.h>
#include <unistd.h>

int main(){
 puts(
  strcmp(getpwuid(geteuid())->pw_name, "root") ?
   "not running as root"
   : "running as root"
 );
 return 0;
}

Name: Anonymous 2008-01-22 20:42

>>13
On what Unix system is uid 0 not the superuser (commonly referred to as `root')?

Name: Anonymous 2008-01-22 20:49

>>13
Wrong.

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
  printf("I am%s root.\n", strcmp(*argv, "root") ? " not" : "");
  return 0;
}

Name: Anonymous 2008-01-22 20:55

>>15
ic wut u did thar.

Name: Anonymous 2008-01-22 21:38

>>14
none that i know of.
it is however, quite possible for "root" to not be the superuser.
>>1 said "root", not "uid 0" or "superuser".

>>15
$ perl -e"exec{'./>>15\'s shitty program'}'root'"
I am root.
$

OH SHI-

Name: Anonymous 2008-01-22 21:49

You read POSIX reference book 138, page 2553, chapter 57, paragraph 2 to 9.

Name: Captain Obvious 2008-01-22 23:34

>>17
You're deliberately misunderstanding >>1's intent in an attempt to troll!

Name: Anonymous 2008-01-23 3:38

>>15
LOL

Name: 11 2008-01-23 7:50

>>12,13
lol no shit fags

Name: root 2008-01-23 8:08

I am root.

Name: Anonymous 2008-01-23 8:31

whoami

Name: Anonymous 2008-01-23 8:45

>>13
Learn how to read from the context. Why the fuck would >>1 want to make his program work for the root user but not sudo?

Name: Anonymous 2008-01-23 14:48

>>24
Learn how to do exactly what the spec says, whether it's stupid or not.
Leave decisions like that to the people who write the spec so you can blame them if it's wrong.

Name: Anonymous 2008-01-23 15:02

>>25
You sound like a corporate code monkey. We don't like your type around here.

Name: Anonymous 2008-01-23 15:07

>>23
I pronounce this ``whoah-me''.

Name: Anonymous 2008-01-23 16:45

[keanu]whoah[/keanu] me.

BBCode must be immediately updated to support that tag.

Name: Anonymous 2008-01-23 20:09

>>27
I lol'd a little in the back of my mouth.

Name: Anonymous 2008-01-23 20:34

>>12
Wrong, wrong, wrong.

Leave /prog/ you fucking woman

Name: moot 2008-01-24 5:36

I am moot.

Name: Anonymous 2008-01-24 5:46

>>30
http://catb.org/jargon/html/verb-doubling.html

Are you an enterprise suit or something.

Name: Anonymous 2008-01-24 5:46

ITT, assholes.

Name: Anonymous 2008-01-24 5:47

>>32
You do realise that citing ESR makes you automatically fail, right?

Name: Anonymous 2008-01-24 5:50

>>34
You do realise that you just got trolled heavily?

Name: Anonymous 2008-01-24 5:54

>>35
The statement that you levelled at me applies more appropriately to yourself.

Name: Anonymous 2008-01-24 5:58

>>36
This might surprise you, but you got it the other way around. Remember the Alamo, asshole.

Name: Anonymous 2008-01-24 6:08

>>37
NO U

Name: Anonymous 2009-03-18 3:34

I'm feeling really keen, for some of that good ol' green

Marijuana MUST be legalized.

Name: Anonymous 2011-01-15 7:40

>>30
Urusei, urusei, urusei!

Don't change these.
Name: Email:
Entire Thread Thread List