mirror of
https://github.com/zhaojh329/rtty.git
synced 2026-02-27 09:53:17 +08:00
+3
-3
@@ -192,12 +192,12 @@ bool detect_file_operation(uint8_t *buf, int len, int sid, struct file_context *
|
||||
|
||||
memcpy(&pid, buf + 4, 4);
|
||||
|
||||
if (!getuid_pid(pid, &uid)) {
|
||||
if (!getuid_by_pid(pid, &uid)) {
|
||||
kill(pid, SIGTERM);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getgid_pid(pid, &gid)) {
|
||||
if (!getgid_by_pid(pid, &gid)) {
|
||||
kill(pid, SIGTERM);
|
||||
return true;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ bool detect_file_operation(uint8_t *buf, int len, int sid, struct file_context *
|
||||
send_file_control_msg(ctlfd, RTTY_FILE_MSG_REQUEST_ACCEPT, NULL, 0);
|
||||
|
||||
memset(savepath, 0, sizeof(savepath));
|
||||
getcwd_pid(pid, savepath, sizeof(savepath) - 1);
|
||||
getcwd_by_pid(pid, savepath, sizeof(savepath) - 1);
|
||||
strcat(savepath, "/");
|
||||
|
||||
ctx->uid = uid;
|
||||
|
||||
+3
-3
@@ -160,7 +160,7 @@ struct mntent *find_mount_point(const char *name)
|
||||
* getcwd_pid does not append a null byte to buf. It will (silently) truncate the contents (to
|
||||
* a length of bufsiz characters), in case the buffer is too small to hold all of the contents.
|
||||
*/
|
||||
ssize_t getcwd_pid(pid_t pid, char *buf, size_t bufsiz)
|
||||
ssize_t getcwd_by_pid(pid_t pid, char *buf, size_t bufsiz)
|
||||
{
|
||||
char link[128];
|
||||
|
||||
@@ -169,7 +169,7 @@ ssize_t getcwd_pid(pid_t pid, char *buf, size_t bufsiz)
|
||||
return readlink(link, buf, bufsiz);
|
||||
}
|
||||
|
||||
bool getuid_pid(pid_t pid, uid_t *uid)
|
||||
bool getuid_by_pid(pid_t pid, uid_t *uid)
|
||||
{
|
||||
char status[128];
|
||||
char line[128];
|
||||
@@ -196,7 +196,7 @@ bool getuid_pid(pid_t pid, uid_t *uid)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool getgid_pid(pid_t pid, gid_t *gid)
|
||||
bool getgid_by_pid(pid_t pid, gid_t *gid)
|
||||
{
|
||||
char status[128];
|
||||
char line[128];
|
||||
|
||||
+3
-3
@@ -38,10 +38,10 @@ const char *format_size(size_t size);
|
||||
|
||||
struct mntent *find_mount_point(const char *name);
|
||||
|
||||
ssize_t getcwd_pid(pid_t pid, char *buf, size_t bufsiz);
|
||||
ssize_t getcwd_by_pid(pid_t pid, char *buf, size_t bufsiz);
|
||||
|
||||
bool getuid_pid(pid_t pid, uid_t *uid);
|
||||
bool getuid_by_pid(pid_t pid, uid_t *uid);
|
||||
|
||||
bool getgid_pid(pid_t pid, gid_t *gid);
|
||||
bool getgid_by_pid(pid_t pid, gid_t *gid);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user