Changeset a77080d567d0ba6598a06af6f02c7ef24bfbadcb
- Timestamp:
- 09/06/08 20:50:41
(4 months ago)
- Author:
- Rémi Denis-Courmont <rdenis@simphalempin.com>
- git-committer:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1213037441 +0300
- git-parent:
[bf19c9ed7a2d45d6a76ab80da12d1ef87315d540]
- git-author:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1213037369 +0300
- Message:
Support for sudo
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd9799c1 |
ra77080d |
|
| 206 | 206 | #endif |
|---|
| 207 | 207 | |
|---|
| 208 | | setuid (getuid ()); |
|---|
| | 208 | uid_t uid = getuid (); |
|---|
| | 209 | if (uid == 0) |
|---|
| | 210 | { |
|---|
| | 211 | const char *sudo = getenv ("SUDO_UID"); |
|---|
| | 212 | if (sudo) |
|---|
| | 213 | uid = atoi (sudo); |
|---|
| | 214 | } |
|---|
| | 215 | if (uid == 0) |
|---|
| | 216 | { |
|---|
| | 217 | fprintf (stderr, "Cannot determine unprivileged user for VLC!\n"); |
|---|
| | 218 | exit (1); |
|---|
| | 219 | } |
|---|
| | 220 | setuid (uid); |
|---|
| 209 | 221 | |
|---|
| 210 | 222 | if (!setuid (0)) /* sanity check: we cannot get root back */ |
|---|
| 211 | 223 | exit (1); |
|---|
| 212 | 224 | |
|---|
| 213 | | /* Yeah, the user can force to execute just about anything from here. |
|---|
| | 225 | /* Yeah, the user can execute just about anything from here. |
|---|
| 214 | 226 | * But we've dropped privileges, so it does not matter. */ |
|---|
| 215 | 227 | if (strlen (argv[0]) < sizeof ("-wrapper")) |
|---|