This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
ubuntu:setuid [2018/02/18 05:50] tschulz |
ubuntu:setuid [2018/02/18 05:54] (current) tschulz |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== SetUid C source ===== | ===== SetUid C source ===== | ||
- | <file c> | + | <file c setuidtest.c> |
#include <stdio.h> | #include <stdio.h> | ||
#include <sys/types.h> | #include <sys/types.h> | ||
Line 27: | Line 27: | ||
} | } | ||
</file> | </file> | ||
+ | |||
+ | ===== Compile and chmod ===== | ||
+ | <file bash> | ||
+ | gcc -o setuidtest setuidtest.c | ||
+ | chmod u+s setuidtest | ||
+ | </file> | ||
+ | |||
+ | ===== Read from stdin ===== | ||
+ | <file c> | ||
+ | char buf[1]; | ||
+ | |||
+ | while(read(0, buf, sizeof(buf))>0) { | ||
+ | // read() here read from stdin charachter by character | ||
+ | // the buf[0] contains the character got by read() | ||
+ | .... | ||
+ | } | ||
+ | </file> | ||
+ | |||