MCPcopy Create free account
hub / github.com/USBGuard/usbguard / usbguard_remove_user

Function usbguard_remove_user

src/CLI/usbguard-remove-user.cpp:66–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 }
65
66 int usbguard_remove_user(int argc, char* argv[])
67 {
68 int opt = 0;
69 bool opt_is_group = false;
70
71 while ((opt = getopt_long(argc, argv, options_short, options_long, nullptr)) != -1) {
72 switch (opt) {
73 case 'u':
74 opt_is_group = false;
75 break;
76
77 case 'g':
78 opt_is_group = true;
79 break;
80
81 case 'h':
82 showHelp(std::cout);
83 return EXIT_SUCCESS;
84
85 case '?':
86 showHelp(std::cerr);
87
88 default:
89 return EXIT_FAILURE;
90 }
91 }
92
93 argv += optind;
94 argc -= optind;
95
96 if (argc != 1) {
97 showHelp(std::cerr);
98 return EXIT_FAILURE;
99 }
100
101 if (!(getuid() == 0 && geteuid() == 0)) {
102 USBGUARD_LOG(Error) << "This subcommand requires root privileges. Please retry as root.";
103 return EXIT_FAILURE;
104 }
105
106 const std::string name(argv[0]);
107 const std::string path(getIPCAccessControlFilesPath());
108 removeIPCAccessControlFile(path, name, opt_is_group);
109 return EXIT_SUCCESS;
110 }
111} /* namespace usbguard */
112
113/* vim: set ts=2 sw=2 et */

Callers

nothing calls this directly

Calls 3

showHelpFunction · 0.70

Tested by

no test coverage detected