obj->data.s = buf;
print_pid_stdout(obj, p, p_max_size);
}
+ OBJ(pid_uid) {
+ char buf[max_user_text];
+
+ generate_text_internal(buf, max_user_text, *obj->sub, cur);
+ obj->data.s = buf;
+ print_pid_uid(obj, p, p_max_size);
+ }
+ OBJ(pid_euid) {
+ char buf[max_user_text];
+
+ generate_text_internal(buf, max_user_text, *obj->sub, cur);
+ obj->data.s = buf;
+ print_pid_euid(obj, p, p_max_size);
+ }
+ OBJ(pid_suid) {
+ char buf[max_user_text];
+
+ generate_text_internal(buf, max_user_text, *obj->sub, cur);
+ obj->data.s = buf;
+ print_pid_suid(obj, p, p_max_size);
+ }
+ OBJ(pid_fsuid) {
+ char buf[max_user_text];
+
+ generate_text_internal(buf, max_user_text, *obj->sub, cur);
+ obj->data.s = buf;
+ print_pid_fsuid(obj, p, p_max_size);
+ }
+ OBJ(pid_gid) {
+ char buf[max_user_text];
+
+ generate_text_internal(buf, max_user_text, *obj->sub, cur);
+ obj->data.s = buf;
+ print_pid_gid(obj, p, p_max_size);
+ }
+ OBJ(pid_egid) {
+ char buf[max_user_text];
+
+ generate_text_internal(buf, max_user_text, *obj->sub, cur);
+ obj->data.s = buf;
+ print_pid_egid(obj, p, p_max_size);
+ }
+ OBJ(pid_sgid) {
+ char buf[max_user_text];
+
+ generate_text_internal(buf, max_user_text, *obj->sub, cur);
+ obj->data.s = buf;
+ print_pid_sgid(obj, p, p_max_size);
+ }
+ OBJ(pid_fsgid) {
+ char buf[max_user_text];
+
+ generate_text_internal(buf, max_user_text, *obj->sub, cur);
+ obj->data.s = buf;
+ print_pid_fsgid(obj, p, p_max_size);
+ }
OBJ(processes) {
spaced_print(p, p_max_size, "%hu", 4, cur->procs);
}
END OBJ_ARG(pid_stdout, 0, "pid_stdout needs a pid as argument")
obj->sub = malloc(sizeof(struct text_object));
extract_variable_text_internal(obj->sub, arg);
+ END OBJ_ARG(pid_uid, 0, "pid_uid needs a pid as argument")
+ obj->sub = malloc(sizeof(struct text_object));
+ extract_variable_text_internal(obj->sub, arg);
+ END OBJ_ARG(pid_euid, 0, "pid_euid needs a pid as argument")
+ obj->sub = malloc(sizeof(struct text_object));
+ extract_variable_text_internal(obj->sub, arg);
+ END OBJ_ARG(pid_suid, 0, "pid_suid needs a pid as argument")
+ obj->sub = malloc(sizeof(struct text_object));
+ extract_variable_text_internal(obj->sub, arg);
+ END OBJ_ARG(pid_fsuid, 0, "pid_fsuid needs a pid as argument")
+ obj->sub = malloc(sizeof(struct text_object));
+ extract_variable_text_internal(obj->sub, arg);
+ END OBJ_ARG(pid_gid, 0, "pid_gid needs a pid as argument")
+ obj->sub = malloc(sizeof(struct text_object));
+ extract_variable_text_internal(obj->sub, arg);
+ END OBJ_ARG(pid_egid, 0, "pid_egid needs a pid as argument")
+ obj->sub = malloc(sizeof(struct text_object));
+ extract_variable_text_internal(obj->sub, arg);
+ END OBJ_ARG(pid_sgid, 0, "pid_sgid needs a pid as argument")
+ obj->sub = malloc(sizeof(struct text_object));
+ extract_variable_text_internal(obj->sub, arg);
+ END OBJ_ARG(pid_fsgid, 0, "pid_fsgid needs a pid as argument")
+ obj->sub = malloc(sizeof(struct text_object));
+ extract_variable_text_internal(obj->sub, arg);
END OBJ(processes, &update_total_processes)
END OBJ(running_processes, &update_running_processes)
#ifdef __linux__
case OBJ_pid_stderr:
case OBJ_pid_stdin:
case OBJ_pid_stdout:
+ case OBJ_pid_uid:
+ case OBJ_pid_euid:
+ case OBJ_pid_suid:
+ case OBJ_pid_fsuid:
+ case OBJ_pid_gid:
+ case OBJ_pid_egid:
+ case OBJ_pid_sgid:
+ case OBJ_pid_fsgid:
if(obj->sub) {
free_text_objects(obj->sub, 1);
free(obj->sub);
NORM_ERR(READERR, PROCDIR);
}
}
+
+#define UID_ENTRY "Uid:\t"
+void print_pid_uid(struct text_object *obj, char *p, int p_max_size) {
+#define UIDNOTFOUND "Can't find the process real uid in '%s'"
+ char *begin, *end, *buf = NULL;
+ int bytes_read;
+
+ asprintf(&buf, PROCDIR "/%s/status", obj->data.s);
+ strcpy(obj->data.s, buf);
+ free(buf);
+ buf = readfile(obj->data.s, &bytes_read, 1);
+ if(buf != NULL) {
+ begin = strstr(buf, UID_ENTRY);
+ if(begin != NULL) {
+ begin += strlen(UID_ENTRY);
+ end = strchr(begin, '\t');
+ if(end != NULL) {
+ *(end) = 0;
+ }
+ snprintf(p, p_max_size, "%s", begin);
+ } else {
+ NORM_ERR(UIDNOTFOUND, obj->data.s);
+ }
+ free(buf);
+ }
+}
+
+void print_pid_euid(struct text_object *obj, char *p, int p_max_size) {
+#define EUIDNOTFOUND "Can't find the process effective uid in '%s'"
+ char *begin, *end, *buf = NULL;
+ int bytes_read;
+
+ asprintf(&buf, PROCDIR "/%s/status", obj->data.s);
+ strcpy(obj->data.s, buf);
+ free(buf);
+ buf = readfile(obj->data.s, &bytes_read, 1);
+ if(buf != NULL) {
+ begin = strstr(buf, UID_ENTRY);
+ if(begin != NULL) {
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ end = strchr(begin, '\t');
+ if(end != NULL) {
+ *(end) = 0;
+ }
+ snprintf(p, p_max_size, "%s", begin);
+ } else {
+ NORM_ERR(EUIDNOTFOUND, obj->data.s);
+ }
+ free(buf);
+ }
+}
+
+void print_pid_suid(struct text_object *obj, char *p, int p_max_size) {
+#define SUIDNOTFOUND "Can't find the process saved set uid in '%s'"
+ char *begin, *end, *buf = NULL;
+ int bytes_read;
+
+ asprintf(&buf, PROCDIR "/%s/status", obj->data.s);
+ strcpy(obj->data.s, buf);
+ free(buf);
+ buf = readfile(obj->data.s, &bytes_read, 1);
+ if(buf != NULL) {
+ begin = strstr(buf, UID_ENTRY);
+ if(begin != NULL) {
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ end = strchr(begin, '\t');
+ if(end != NULL) {
+ *(end) = 0;
+ }
+ snprintf(p, p_max_size, "%s", begin);
+ } else {
+ NORM_ERR(SUIDNOTFOUND, obj->data.s);
+ }
+ free(buf);
+ }
+}
+
+void print_pid_fsuid(struct text_object *obj, char *p, int p_max_size) {
+#define FSUIDNOTFOUND "Can't find the process file system uid in '%s'"
+ char *begin, *end, *buf = NULL;
+ int bytes_read;
+
+ asprintf(&buf, PROCDIR "/%s/status", obj->data.s);
+ strcpy(obj->data.s, buf);
+ free(buf);
+ buf = readfile(obj->data.s, &bytes_read, 1);
+ if(buf != NULL) {
+ begin = strstr(buf, UID_ENTRY);
+ if(begin != NULL) {
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ end = strchr(begin, '\n');
+ if(end != NULL) {
+ *(end) = 0;
+ }
+ snprintf(p, p_max_size, "%s", begin);
+ } else {
+ NORM_ERR(FSUIDNOTFOUND, obj->data.s);
+ }
+ free(buf);
+ }
+}
+
+#define GID_ENTRY "Gid:\t"
+void print_pid_gid(struct text_object *obj, char *p, int p_max_size) {
+#define GIDNOTFOUND "Can't find the process real gid in '%s'"
+ char *begin, *end, *buf = NULL;
+ int bytes_read;
+
+ asprintf(&buf, PROCDIR "/%s/status", obj->data.s);
+ strcpy(obj->data.s, buf);
+ free(buf);
+ buf = readfile(obj->data.s, &bytes_read, 1);
+ if(buf != NULL) {
+ begin = strstr(buf, GID_ENTRY);
+ if(begin != NULL) {
+ begin += strlen(GID_ENTRY);
+ end = strchr(begin, '\t');
+ if(end != NULL) {
+ *(end) = 0;
+ }
+ snprintf(p, p_max_size, "%s", begin);
+ } else {
+ NORM_ERR(GIDNOTFOUND, obj->data.s);
+ }
+ free(buf);
+ }
+}
+
+void print_pid_egid(struct text_object *obj, char *p, int p_max_size) {
+#define EGIDNOTFOUND "Can't find the process effective gid in '%s'"
+ char *begin, *end, *buf = NULL;
+ int bytes_read;
+
+ asprintf(&buf, PROCDIR "/%s/status", obj->data.s);
+ strcpy(obj->data.s, buf);
+ free(buf);
+ buf = readfile(obj->data.s, &bytes_read, 1);
+ if(buf != NULL) {
+ begin = strstr(buf, GID_ENTRY);
+ if(begin != NULL) {
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ end = strchr(begin, '\t');
+ if(end != NULL) {
+ *(end) = 0;
+ }
+ snprintf(p, p_max_size, "%s", begin);
+ } else {
+ NORM_ERR(EGIDNOTFOUND, obj->data.s);
+ }
+ free(buf);
+ }
+}
+
+void print_pid_sgid(struct text_object *obj, char *p, int p_max_size) {
+#define SGIDNOTFOUND "Can't find the process saved set gid in '%s'"
+ char *begin, *end, *buf = NULL;
+ int bytes_read;
+
+ asprintf(&buf, PROCDIR "/%s/status", obj->data.s);
+ strcpy(obj->data.s, buf);
+ free(buf);
+ buf = readfile(obj->data.s, &bytes_read, 1);
+ if(buf != NULL) {
+ begin = strstr(buf, GID_ENTRY);
+ if(begin != NULL) {
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ end = strchr(begin, '\t');
+ if(end != NULL) {
+ *(end) = 0;
+ }
+ snprintf(p, p_max_size, "%s", begin);
+ } else {
+ NORM_ERR(SGIDNOTFOUND, obj->data.s);
+ }
+ free(buf);
+ }
+}
+
+void print_pid_fsgid(struct text_object *obj, char *p, int p_max_size) {
+#define FSGIDNOTFOUND "Can't find the process file system gid in '%s'"
+ char *begin, *end, *buf = NULL;
+ int bytes_read;
+
+ asprintf(&buf, PROCDIR "/%s/status", obj->data.s);
+ strcpy(obj->data.s, buf);
+ free(buf);
+ buf = readfile(obj->data.s, &bytes_read, 1);
+ if(buf != NULL) {
+ begin = strstr(buf, GID_ENTRY);
+ if(begin != NULL) {
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ begin = strchr(begin, '\t'); begin++;
+ end = strchr(begin, '\n');
+ if(end != NULL) {
+ *(end) = 0;
+ }
+ snprintf(p, p_max_size, "%s", begin);
+ } else {
+ NORM_ERR(FSGIDNOTFOUND, obj->data.s);
+ }
+ free(buf);
+ }
+}