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

Pages: 1-

kernel code question

Name: Anonymous 2009-10-10 5:33

Yes, this is homework. No, I don't want /prog/ to do it for me, I'm simply not quite sure how to do something and would like a push in the right direction or a reference of some sort.

In brief, I am implementing a new syscall in the Linux kernel, and I need to get the user making the system call. Poking around told me that it is better to get the UID with getuid() because the kernel doesn't know about usernames, but how do I then get the username?

I hate this course, we learn general theory about operating system design (which is great) but then suddenly we are told to do specific modifications in the Linux kernel without having been taught the basics of how things work in the Linux kernel. i have no aversion to learning on my own, but that is a LOT to learn in a couple weeks' time with a full schedule.

Anyway, any gentle nudge in the right direction would be greatly appreciated.

Name: Anonymous 2009-10-10 5:34

Oh and before anyone comments, yes, I've looked around a lot on my own, including looking through the Linux kernel API as available online and I haven't found what I need, unless I missed something.

Name: Anonymous 2009-10-10 5:39

/etc/passwd

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !frozEn/KIg 2009-10-10 5:41

http://tldp.org/HOWTO/html_single/Implement-Sys-Call-Linux-2.6-i386/



__________________________________
http://bayimg.com/image/aadbjaace.jpg
Now Playing:The End of All Hope by Nightwish
My Blog: http://frozenvoid.blogspot.com/
«Death cannot be struggled against, brother. It ever arrives, defiant of every hiding place, of every frantic attempt to escape. Death is every mortal's shadow, his true shadow, and time is its servant, spinning that shadow slowly round, until what stretched before one now stretched before him.»

Name: Anonymous 2009-10-10 5:43

>>3
this was my first thought, then i googled for a second and found this:
http://linux.die.net/man/3/getlogin_r

Name: Anonymous 2009-10-10 5:51

Thanks for the replies, but I think I phrased my problem incorrectly - sorry, I'm tired.

The code I'm writing runs in the kernel, and I need to get the username of the user that made the system call. In the function I wrote, how might I go about finding out which user has called the function? I looked at getuid() for example, but that returns the UID of the current process, and therefore doesn't make sense to call within the kernel.

I am getting data from user space memory, so my first thought was whether there is some way to check which process (and thus which UID and which username) is associated with the memory being passed, I'm still googling but I haven't found anything.

Name: Anonymous 2009-10-10 5:59

Why would you need username? uid is all you need. If you need actual user name from /etc/passwd in your syscall, you made some serious mistake while designing it.

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !frozEn/KIg 2009-10-10 6:05

He is using some security module probably.
try parsing cap_user_header_t  http://bluemaster.iu.hio.no/edu/ca/lin-asm/syscalls.html
which contains the PID and match it to valid usernames.



____________________________________________
http://bayimg.com/image/aadbjaace.jpg
My Blog: http://frozenvoid.blogspot.com/
«Stop having subversive thoughts.»

Name: Anonymous 2009-10-10 6:11

>>6
ah. i think i understand now.
the system call should be passed a pointer to a structure (a thread struct in freebsd).
you should be able to get the uid from that.
i've never done this so i don't know for sure, but i would start by looking at what that structure contains if i was you.

Name: Anonymous 2009-10-10 13:37

if I was you
were

Name: Anonymous 2010-12-21 14:59

Name: Anonymous 2011-02-02 22:44

Name: Anonymous 2012-05-29 7:21


██████████████████████████▛█▜▜▝▘ ▗▗▗▖▌▛▜▀▜███████████████████████
██████████████████████▛▀▘      ▝   ▗▄▄█▙█████████████████████████
████████████████████▀▀ ▘    ▗    ▐▛▌▀▘▘▗▝▘▖▛█████████████████████
███████████████████▖▀  ▗▖    ▖▝ ▀▘        ▞▝▘████████████████████
████████████████▜▟▗ ▗▄▜▚  ▖                ▖▝▟▝▀▀▜███████████████
███████████████▟█▄▟▟██▘ ▗▚▘▘                    ▗▞█▜█████████████
█████████████████████▚▐▟▛▝     ▖               ▝▟▖▝ ▝▀▀▚▞▜███████
████████████████████▙██▛                        ▝▙      ▚ ▖▀█████
█████████████████████▛▘▗▄▀▘▘                     ▜▖      █  ▝▜███
███████████████████▛▚▄▐▘ ▗▗                      ▐█      ▝▞▗  ▐██
█████████████████▛██▙▙▞▀▀  ▗▗▄▗▖                  █▙▗     ▚    ▀█
████████████████▙████▙██▀▜▄▝▛▞▀▀▜██▙▄▄▖▖           █▙▚▖         ▀
███████████████████████▄▀       ▟█████▛▜▘▖         ▟█▙█▖   ▗    
██████████▜███████████▛         ▄█████▄▖           ▐████▖     ▐▖
██████████████████████▙       ▗▟████████▙          ▝████▙     ▝█▝
█████████████████████▛▘      ▝████████▟▛▜██▄▖       ▝████▖ ▚▚▙ ▚▘
████████████████▝▝▀▀▘        ▝▀▀▛████▜██▟▐███▙      ▗████▙ ▞▘▗▘▞▖
███████▛▀▝▀ ▝   ▘               ▀▀▛████████████▖     ▟████▞▐▘ ▌▝▞
█████▛            ▖               ▝ ▞▘▖▀█▜▜▜██▛▌     ▜████▙▝▙▖▙▙
████▌             ▗  ▄██▖                            ▝████▙▘▄ ▐▚▖
███▘             ▐█▙ ▐██▙                             ▐████▌▙ ▜▐▞
███              █████▛▝▜▙▖                           ▝█████▌▛▙▚▙
██▌             ▝▘▘▀▀▘  ▝▜▙▌                           ██████▞▛▟▙
██▖                                                    ███████▙▗█
█▙             ▗▄▄▙▙▄                                  ▟██████▛▞▙
█▙            ▄███████▙▄                               ███████▟██
██          ▗████████████▖                           ▗▟███████▙█▛
█▛        ▄▟██▛██▖▛▛▛▜▜███▙▖                         ▄██████████▞
█▌         ▀▀      ▘▀▀▀█████▙                   ▖▖  ▐████████████
█             ▖▄▄▄▄▄▄▄   ▘▀▀▀                  ▘    ▜████████████
█              ▀▜▜█▛▛▀▀▝                           ▐█████████████
▙                                                  ▜█████████████
▙                                                  ██████████████
█▙                                                 ██████████████
██▄                                               ▜██████████████
██▛▀▖ ▗▗      ▗▄ ▗                               ▄███████████████
██▙▜           ▀▀▀███████▙█▙▄▙▄▙▄▄▄▄▄▄▟▄▟▙▙▄▄▄▟▟█████████████████
████▙              ▀▟████████████████████████████████████████████
███████▄           ▀█████████████████████████████████████████████
█████████▄          ▜████████████████████████████████████████████
██████████▙▖         ▜███████████████████████████████████████████
████████████▌▖      ▌▝▟███████████████████████▜▜█████████████████
█████████████▙▙     ▝▖██████████████████████▘  ▟████████▛████████
███████████████▙▖ ▗▐▗▖███████████████████▛▀   ▝████████▛▟███████▛

Name: Anonymous 2012-05-29 7:26


                       ▄▄▄▄▄▄▄▄▄▖                          
                   ▄▄███████████████████▄                  
                ▄▟████████████████████████▄                
               ▟████████████████████████████▖              
              ▄███████████▛▀▀▗▞▀▀▀▜██████████▄             
            ▄██████████▀▘           ▗█████████▙            
          ▄██████████▀                ▐█████████▖          
        ▗██████████▀                   █████████▙          
        ███████▛▀▘                     ▄██████████▖        
       ▐███████                        ▀███████████▖▄▄     
      ▗▟██████                        ▝█████████████       
      ▗██████▘                        ▗▙▐▀██████████▌      
      ███████▛                          ▗█▜███████████▖    
     ▗███████▌                          ▗▄█████████████▙   
    ▗▟███████▙                         ▝▙█▟█████████████▘  
    ▄█████████                          ▐████████████████▙ 
    ██████████                ▗▄▄████▄▖ ▝████████████████ ▌
    █████████▛  ▄▄▄▄          ▝██▛▀▀▀▀██▄▀███████████████▌ 
   ▐█████████████████▌         ▄▖    ▄▟███████████████████▖▝
  ▐████████████▀      ▗▄▖    ▄▟████▄▄████▄▜█▛█████████████▌
  ▗████████████▙▄▄██████▄   ▐▛▀▛▀▝▜███▜██▙▖ ▚ ▜█████████████
  ▄████████████████▛▀▜▄▐▛   ▜▙▛▜█▙▝   ▀███▙   ▝█████████████
 ▗█████████████▙▀█▀▀▀▀▀▟▖   ▐█▄ ▝ ▗   ▝▀▘▀    ▝█████████████
▗▟██████████████▝▘ ▗▄▗██▖    ▀▜▘              ▐█████████████
▐██████████████▛▀▝▀▘ ▐█▛                      ▐█████████████
▄████████████        ▐█▌                       █████████████
███████████▛          ▟▌    ▐▖                 ▝████████████
███████████▘         ▗▟      ▀▀▚▖              █████████████
███████████▙         ▟▄      ▗▖ ▗              ▟████████████
████████████         ██▙▄  ▟██▛▜▌             ▗█████████████
████████████         ▜▙▟█▙▟██▄█▄██▙ ▖          ▟████████████
████████████        ▄████▟█▐███████████       ▗█████████████
███████████▌▀      █████████████████████▖      ▟████████████
█████████████    ▗██████████████████████▌    ███████████████
████████████     ███████████████████████▙   ▐▖██████████████
█████████████▌ ▐██████████▛▀▀▀▜██▛▜██████   ▄███████████████
█████████████▙██████████▘      ▄▟████████▟██▐███████████████
██████████████████████████▛▙▄▖▝▀▀█▛▘▐████▀██████████████████
████████████████████▄▝▜██▌       ▗▄▝▜████▟██████████████████
████████████████████▖▖▜▛▚▄█▟▌▖▗▗▄▄█▄ ███████████████████████
█████████████████████▙█████████████▌ ▄██████████████████████
████████████████████████████████████▟███████████████████████
████████████████████████████████████████████████████████████
████████████████████████████████████████████████████████████
████████████████████████████████████████████████████████████
████████████████████████████████████████████████████████████
████████████████████████████████████████████████████████████

Name: Anonymous 2012-05-29 7:28


██████████████████████████▛█▜▜▝▘ ▗▗▗▖▌▛▜▀▜███████████████████████
██████████████████████▛▀▘      ▝   ▗▄▄█▙█████████████████████████
████████████████████▀▀ ▘    ▗    ▐▛▌▀▘▘▗▝▘▖▛█████████████████████
███████████████████▖▀  ▗▖    ▖▝ ▀▘        ▞▝▘████████████████████
████████████████▜▟▗ ▗▄▜▚  ▖                ▖▝▟▝▀▀▜███████████████
███████████████▟█▄▟▟██▘ ▗▚▘▘                    ▗▞█▜█████████████
█████████████████████▚▐▟▛▝     ▖               ▝▟▖▝ ▝▀▀▚▞▜███████
████████████████████▙██▛                        ▝▙      ▚ ▖▀█████
█████████████████████▛▘▗▄▀▘▘                     ▜▖      █  ▝▜███
███████████████████▛▚▄▐▘ ▗▗                      ▐█      ▝▞▗  ▐██
█████████████████▛██▙▙▞▀▀  ▗▗▄▗▖                  █▙▗     ▚    ▀█
████████████████▙████▙██▀▜▄▝▛▞▀▀▜██▙▄▄▖▖           █▙▚▖         ▀
███████████████████████▄▀       ▟█████▛▜▘▖         ▟█▙█▖   ▗    
██████████▜███████████▛         ▄█████▄▖           ▐████▖     ▐▖
██████████████████████▙       ▗▟████████▙          ▝████▙     ▝█▝
█████████████████████▛▘      ▝████████▟▛▜██▄▖       ▝████▖ ▚▚▙ ▚▘
████████████████▝▝▀▀▘        ▝▀▀▛████▜██▟▐███▙      ▗████▙ ▞▘▗▘▞▖
███████▛▀▝▀ ▝   ▘               ▀▀▛████████████▖     ▟████▞▐▘ ▌▝▞
█████▛            ▖               ▝ ▞▘▖▀█▜▜▜██▛▌     ▜████▙▝▙▖▙▙
████▌             ▗  ▄██▖                            ▝████▙▘▄ ▐▚▖
███▘             ▐█▙ ▐██▙                             ▐████▌▙ ▜▐▞
███              █████▛▝▜▙▖                           ▝█████▌▛▙▚▙
██▌             ▝▘▘▀▀▘  ▝▜▙▌                           ██████▞▛▟▙
██▖                                                    ███████▙▗█
█▙             ▗▄▄▙▙▄                                  ▟██████▛▞▙
█▙            ▄███████▙▄                               ███████▟██
██          ▗████████████▖                           ▗▟███████▙█▛
█▛        ▄▟██▛██▖▛▛▛▜▜███▙▖                         ▄██████████▞
█▌         ▀▀      ▘▀▀▀█████▙                   ▖▖  ▐████████████
█             ▖▄▄▄▄▄▄▄   ▘▀▀▀                  ▘    ▜████████████
█              ▀▜▜█▛▛▀▀▝                           ▐█████████████
▙                                                  ▜█████████████
▙                                                  ██████████████
█▙                                                 ██████████████
██▄                                               ▜██████████████
██▛▀▖ ▗▗      ▗▄ ▗                               ▄███████████████
██▙▜           ▀▀▀███████▙█▙▄▙▄▙▄▄▄▄▄▄▟▄▟▙▙▄▄▄▟▟█████████████████
████▙              ▀▟████████████████████████████████████████████

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