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

Method openExecutable

src/CLI/IPCSignalWatcher.cpp:171–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169 }
170
171 void IPCSignalWatcher::openExecutable(const std::string& path)
172 {
173 const int fd = ::open(path.c_str(), O_RDONLY);
174
175 if (fd < 0) {
176 throw ErrnoException("openExecutable", path, errno);
177 }
178
179 struct ::stat st = { };
180
181 if (::fstat(fd, &st) != 0) {
182 ::close(fd);
183 throw ErrnoException("openExecutable", path, errno);
184 }
185
186 if (!S_ISREG(st.st_mode) || !(st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))) {
187 ::close(fd);
188 throw Exception("openExecutable", path, "not an executable file");
189 }
190
191 _exec_path = path;
192 _exec_path_fd = fd;
193 }
194
195 void IPCSignalWatcher::closeExecutable()
196 {

Callers

nothing calls this directly

Calls 2

ErrnoExceptionClass · 0.85
ExceptionFunction · 0.85

Tested by

no test coverage detected