|
Revision 862, 2.0 KB
(checked in by mario.izquierdo, 16 months ago)
|
|
max-multiseat-storage (6.0.max2)
- Add license headers and cosmetic changes
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #include <stdio.h> |
|---|
| 22 | #include <unistd.h> |
|---|
| 23 | #include <sys/types.h> |
|---|
| 24 | #include <string.h> |
|---|
| 25 | |
|---|
| 26 | #include <stdlib.h> |
|---|
| 27 | |
|---|
| 28 | int snprintf(char *str, size_t size, const char *format, ...); |
|---|
| 29 | char *fgets(char *s, int tam, FILE *flujo); |
|---|
| 30 | FILE *popen(const char *orden, const char *tipo); |
|---|
| 31 | int pclose(FILE *flujo); |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | #define BSIZE 1024 |
|---|
| 35 | #define APP "/usr/sbin/multiseat-udisks" |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | void remove_line_break( char *s ) { |
|---|
| 39 | s[strcspn ( s, "\n" )] = '\0'; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | int main (int argc, char **argv) { |
|---|
| 44 | uid_t my_uid=0; |
|---|
| 45 | uid_t my_euid=0; |
|---|
| 46 | FILE *fp; |
|---|
| 47 | char cmd[BSIZE]=""; |
|---|
| 48 | char line[BSIZE]=""; |
|---|
| 49 | char *fret; |
|---|
| 50 | |
|---|
| 51 | if (argc != 2) { |
|---|
| 52 | return 1; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | my_uid=getuid(); |
|---|
| 56 | my_euid=geteuid(); |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | snprintf( (char*) cmd, BSIZE, "%s %s %d 2>&1", APP, argv[1], my_uid); |
|---|
| 64 | |
|---|
| 65 | if ( setuid(0) ) { |
|---|
| 66 | printf("/sbin/umount.multiseat: No se pudieron elevar los privilegios.\n"); |
|---|
| 67 | return 1; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | fp=(FILE*)popen( cmd , "r"); |
|---|
| 71 | if (fp == NULL) { |
|---|
| 72 | printf("/sbin/umount.multiseat: No se pudo ejecutar la aplicación esclava.\n"); |
|---|
| 73 | return 1; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | fret = fgets( line, sizeof line, fp); |
|---|
| 77 | remove_line_break(line); |
|---|
| 78 | pclose(fp); |
|---|
| 79 | |
|---|
| 80 | printf("%s\n",line); |
|---|
| 81 | return 0; |
|---|
| 82 | } |
|---|