Send DevNodeSkipped message type when extracting device nodewithout root
priv
This commit is contained in:
parent
374de790a7
commit
d63b9f29d0
4 changed files with 13 additions and 4 deletions
14
haggis.c
14
haggis.c
|
@ -39,6 +39,7 @@
|
|||
#include <limits.h> // PATH_MAX
|
||||
#include <stddef.h> // size_t
|
||||
#include <stdint.h> // uint<x>_t
|
||||
#include <sys/syslimits.h>
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <sha.h>
|
||||
|
@ -886,11 +887,16 @@ int haggis_extract_node(char *basedir, haggis_node *node, haggis_mq *mq) {
|
|||
switch (node->filetype.tag) {
|
||||
case block:
|
||||
case character:
|
||||
if (geteuid() == 0)
|
||||
if (geteuid() == 0) {
|
||||
ret = haggis_extract_dev(node, basedir);
|
||||
// todo: Add message type for skipped file and add it to queue if we're
|
||||
// not root when calling this. We want this to be a warning, but not a
|
||||
// fatal error.
|
||||
} else {
|
||||
ret = -1;
|
||||
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;
|
||||
case fifo:
|
||||
ret = haggis_extract_fifo(node, basedir);
|
||||
|
|
|
@ -135,6 +135,7 @@ typedef struct {
|
|||
} haggis_linkmap;
|
||||
|
||||
typedef enum {
|
||||
DevNodeSkipped,
|
||||
NodeCreated,
|
||||
NodeExtracted,
|
||||
EndOfArchive,
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "haggis.h"
|
||||
|
||||
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_push(haggis_mq *queue, haggis_msg *msg);
|
||||
haggis_msg* haggis_mq_pop(haggis_mq *queue);
|
||||
|
|
1
mq.c
1
mq.c
|
@ -48,6 +48,7 @@ haggis_msg* haggis_msg_init(haggis_message_type tag, haggis_message_body body) {
|
|||
|
||||
void haggis_msg_deinit(haggis_msg *msg) {
|
||||
switch (msg->tag) {
|
||||
case DevNodeSkipped:
|
||||
case NodeCreated:
|
||||
case NodeExtracted:
|
||||
free(msg->body.f_name);
|
||||
|
|
Loading…
Add table
Reference in a new issue