Send DevNodeSkipped message type when extracting device nodewithout root

priv
This commit is contained in:
Nathan Fisher 2023-10-03 13:16:25 -04:00
parent 374de790a7
commit d63b9f29d0
4 changed files with 13 additions and 4 deletions

View file

@ -39,6 +39,7 @@
#include <limits.h> // PATH_MAX #include <limits.h> // PATH_MAX
#include <stddef.h> // size_t #include <stddef.h> // size_t
#include <stdint.h> // uint<x>_t #include <stdint.h> // uint<x>_t
#include <sys/syslimits.h>
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
#include <sha.h> #include <sha.h>
@ -886,11 +887,16 @@ int haggis_extract_node(char *basedir, haggis_node *node, haggis_mq *mq) {
switch (node->filetype.tag) { switch (node->filetype.tag) {
case block: case block:
case character: case character:
if (geteuid() == 0) if (geteuid() == 0) {
ret = haggis_extract_dev(node, basedir); ret = haggis_extract_dev(node, basedir);
// todo: Add message type for skipped file and add it to queue if we're } else {
// not root when calling this. We want this to be a warning, but not a ret = -1;
// fatal error. msg = calloc(1, sizeof(haggis_msg));
if (msg == NULL) return 2;
msg->tag = DevNodeSkipped;
msg->body.f_name = strndup(node->name.name, PATH_MAX);
haggis_mq_push(mq, msg);
}
break; break;
case fifo: case fifo:
ret = haggis_extract_fifo(node, basedir); ret = haggis_extract_fifo(node, basedir);

View file

@ -135,6 +135,7 @@ typedef struct {
} haggis_linkmap; } haggis_linkmap;
typedef enum { typedef enum {
DevNodeSkipped,
NodeCreated, NodeCreated,
NodeExtracted, NodeExtracted,
EndOfArchive, EndOfArchive,

View file

@ -37,6 +37,7 @@
#include "haggis.h" #include "haggis.h"
haggis_msg* haggis_msg_init(haggis_message_type tag, haggis_message_body body); haggis_msg* haggis_msg_init(haggis_message_type tag, haggis_message_body body);
void haggis_msg_deinit(haggis_msg *msg);
int haggis_mq_init(haggis_mq *mq); int haggis_mq_init(haggis_mq *mq);
int haggis_mq_push(haggis_mq *queue, haggis_msg *msg); int haggis_mq_push(haggis_mq *queue, haggis_msg *msg);
haggis_msg* haggis_mq_pop(haggis_mq *queue); haggis_msg* haggis_mq_pop(haggis_mq *queue);

1
mq.c
View file

@ -48,6 +48,7 @@ haggis_msg* haggis_msg_init(haggis_message_type tag, haggis_message_body body) {
void haggis_msg_deinit(haggis_msg *msg) { void haggis_msg_deinit(haggis_msg *msg) {
switch (msg->tag) { switch (msg->tag) {
case DevNodeSkipped:
case NodeCreated: case NodeCreated:
case NodeExtracted: case NodeExtracted:
free(msg->body.f_name); free(msg->body.f_name);