All about programming in GNU/LINUX

A Simple guide to write programs which can be made use only by a specific user in A GNU/LINUX system using getuid and getlogin system calls

/* hackintosh rao \m/ , codes for GNU/LINUX
   Illustration of code which can only be made use
  System calls used:1) uid_t getuid(void);
                    2) char *getlogin(void); */
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
int main()
{
    uid_t uid;/*uid_t is a build in data type, which can hold small numbers*/
    char* username;
    uid=getuid();
    username=getlogin();
    if(uid==1000)//uid of user karthic
    {
        printf(“\nUID is:%d\nWELCOME Username:%s\n\n\n “,uid,username);
        printf(“\nI AM AT YOUR SERVICE\n\n”);
        /*write functionalities here which can only be made use by user with UId 1000*/
        /*not even can root can unlock this,if if root executes the code he cannot make use of it*/

    }
    else
     printf(“\nWrong User, the program is authorized to be used only by %s\n\n”,username);

    return 0;
}
Image

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s