Improve code

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao
2021-01-30 15:08:25 +08:00
parent 2d9fdb37fe
commit fcc13d72ad
3 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -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
View File
@@ -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
View File
@@ -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