-
-
Notifications
You must be signed in to change notification settings - Fork 603
New functions/API for secure launching of external programs #1915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f7cc64d
664b158
236394b
4f06e76
45f5c73
4cd17d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ in the source distribution for its full text. | |
|
|
||
| #include "Macros.h" | ||
| #include "Panel.h" | ||
| #include "ProgramLauncher.h" | ||
| #include "ProvideCurses.h" | ||
| #include "Vector.h" | ||
| #include "XUtils.h" | ||
|
|
@@ -46,6 +47,8 @@ typedef struct OpenFiles_FileData_ { | |
| struct OpenFiles_FileData_* next; | ||
| } OpenFiles_FileData; | ||
|
|
||
| static ProgramLauncher OpenFiles_ProgramLauncher; | ||
|
|
||
| static size_t getIndexForType(char type) { | ||
| switch (type) { | ||
| case 'f': | ||
|
|
@@ -100,6 +103,12 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) { | |
| pdata->cols[getIndexForType('o')] = 8; | ||
| pdata->cols[getIndexForType('i')] = 8; | ||
|
|
||
| ProgramLauncher_setPath(&OpenFiles_ProgramLauncher, "lsof"); | ||
| if (OpenFiles_ProgramLauncher.lastErrno != 0) { | ||
| pdata->error = 1; | ||
| return pdata; | ||
|
Comment on lines
+106
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve the actionable
|
||
| } | ||
|
|
||
| int fdpair[2] = {-1, -1}; | ||
| if (pipe(fdpair) < 0) { | ||
| pdata->error = 1; | ||
|
|
@@ -127,9 +136,18 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) { | |
| close(fdnull); | ||
| char buffer[32] = {0}; | ||
| xSnprintf(buffer, sizeof(buffer), "%d", pid); | ||
| // Use of NULL in variadic functions must have a pointer cast. | ||
| // The NULL constant is not required by standard to have a pointer type. | ||
| execlp("lsof", "lsof", "-P", "-o", "-p", buffer, "-F", (char*)NULL); | ||
|
|
||
| const char* argv[] = { | ||
| "lsof", | ||
| "-P", | ||
| "-o", | ||
| "-p", | ||
| buffer, | ||
| "-F", | ||
| NULL | ||
| }; | ||
| ProgramLauncher_execv_const(&OpenFiles_ProgramLauncher, argv); | ||
|
|
||
| exit(127); | ||
| } | ||
| close(fdpair[1]); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.