|
| 1 | +diff --git a/src/tools/wpctl.c b/src/tools/wpctl.c |
| 2 | +index 9f507ec..27305f9 100644 |
| 3 | +--- a/src/tools/wpctl.c |
| 4 | ++++ b/src/tools/wpctl.c |
| 5 | +@@ -1326,6 +1326,44 @@ clear_default_run (WpCtl * self) |
| 6 | + { |
| 7 | + g_autoptr (WpPlugin) def_nodes_api = NULL; |
| 8 | + gboolean res = FALSE; |
| 9 | ++ g_autoptr (GError) error = NULL; |
| 10 | ++ pid_t ppid, grandparent_pid; |
| 11 | ++ char grandparent_name[1024]; |
| 12 | ++ |
| 13 | ++ /* Get grandparent process name */ |
| 14 | ++ ppid = getppid(); |
| 15 | ++ if (ppid > 0) { |
| 16 | ++ /* Get parent's PPID (which is our grandparent) */ |
| 17 | ++ char parent_status[256]; |
| 18 | ++ snprintf(parent_status, sizeof(parent_status), "/proc/%d/status", ppid); |
| 19 | ++ FILE *fp = fopen(parent_status, "r"); |
| 20 | ++ if (fp) { |
| 21 | ++ char line[256]; |
| 22 | ++ while (fgets(line, sizeof(line), fp)) { |
| 23 | ++ if (sscanf(line, "PPid: %d", &grandparent_pid) == 1) { |
| 24 | ++ break; |
| 25 | ++ } |
| 26 | ++ } |
| 27 | ++ fclose(fp); |
| 28 | ++ } |
| 29 | ++ |
| 30 | ++ /* Check if grandparent is Steam */ |
| 31 | ++ if (grandparent_pid > 0) { |
| 32 | ++ snprintf(grandparent_name, sizeof(grandparent_name), "/proc/%d/comm", grandparent_pid); |
| 33 | ++ fp = fopen(grandparent_name, "r"); |
| 34 | ++ if (fp) { |
| 35 | ++ if (fgets(grandparent_name, sizeof(grandparent_name), fp)) { |
| 36 | ++ grandparent_name[strcspn(grandparent_name, "\n")] = 0; |
| 37 | ++ if (strcmp(grandparent_name, "steam") == 0) { |
| 38 | ++ fprintf(stderr, "Command 'wpctl clear-default' is disabled when run from Steam\n"); |
| 39 | ++ self->exit_code = 1; |
| 40 | ++ goto out; |
| 41 | ++ } |
| 42 | ++ } |
| 43 | ++ fclose(fp); |
| 44 | ++ } |
| 45 | ++ } |
| 46 | ++ } |
| 47 | + |
| 48 | + def_nodes_api = wp_plugin_find (self->core, "default-nodes-api"); |
| 49 | + if (!def_nodes_api) { |
0 commit comments