aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-10-28 11:41:49 +0200
committergramanas <anastasis.gramm2@gmail.com>2018-10-28 11:41:49 +0200
commit8ad6cfa33d6a37605599be5673c4acecc7eca5af (patch)
tree5f5d1e5263ba769efdab4d95fbdc28a5808afb76 /src
parentde394e24d0dae3ff879295ab4574d2071c92b77d (diff)
downloadck-8ad6cfa33d6a37605599be5673c4acecc7eca5af.tar.gz
ck-8ad6cfa33d6a37605599be5673c4acecc7eca5af.tar.bz2
ck-8ad6cfa33d6a37605599be5673c4acecc7eca5af.zip
Add root attribute in list, finish manpage
Diffstat (limited to 'src')
-rw-r--r--src/ckutil.c13
-rw-r--r--src/ckutil.h2
-rw-r--r--src/dblayer.c12
3 files changed, 27 insertions, 0 deletions
diff --git a/src/ckutil.c b/src/ckutil.c
index f292e8e..06d12da 100644
--- a/src/ckutil.c
+++ b/src/ckutil.c
@@ -180,3 +180,16 @@ int util_own_grp_copy(const char *dest, const char *original) {
}
return 0;
}
+
+int util_is_link_owned_by_root(const char *link) {
+ if (!link) {
+ return 0;
+ }
+ struct stat buf;
+ if (!lstat(link, &buf)) {
+ if (buf.st_uid == (uid_t)0) {
+ return 1;
+ }
+ }
+ return 0;
+}
diff --git a/src/ckutil.h b/src/ckutil.h
index d653116..9f3cb39 100644
--- a/src/ckutil.h
+++ b/src/ckutil.h
@@ -93,4 +93,6 @@ extern int util_symlink_file(const char *path, const char* dest);
/* Chnage owner and group of `new` and make it like `old`*/
extern int util_own_grp_copy(const char *new, const char* old);
+
+extern int util_is_link_owned_by_root(const char *link);
#endif // CKUTIL_H
diff --git a/src/dblayer.c b/src/dblayer.c
index 33e1682..f517dbe 100644
--- a/src/dblayer.c
+++ b/src/dblayer.c
@@ -526,6 +526,10 @@ int get_program_paths(DB *db, cklist *ckl, const char* pName, int bname, int att
if (sqlite3_column_int(stmt, 2)) {
strcat(entry, " [p]");
}
+ /* root */
+ if (util_is_link_owned_by_root((char *)sqlite3_column_text(stmt, 0))) {
+ strcat(entry, " [root]");
+ }
}
list_add(ckl, entry);
free(tmp);
@@ -560,6 +564,10 @@ int list_get_paths(DB *db, cklist *ckl, int attr) {
if (sqlite3_column_int(stmt, 2)) {
strcat(path, " [p]");
}
+ /* root */
+ if (util_is_link_owned_by_root((char *)sqlite3_column_text(stmt, 0))) {
+ strcat(path, " [root]");
+ }
}
list_add(ckl, path);
}
@@ -640,6 +648,10 @@ int list_get_path_program_tree(DB *db, cklist *ckl, int attr) {
if (sqlite3_column_int(stmt2, 2)) {
strcat(treePath, " [p]");
}
+ /* root */
+ if (util_is_link_owned_by_root((char *)sqlite3_column_text(stmt2, 0))) {
+ strcat(treePath, " [root]");
+ }
}
list_add(ckl, treePath);
}