10 INSTANCE_ATTR_COMMAND
,
15 INSTANCE_ATTR_TRIGGER
,
16 INSTANCE_ATTR_RESPAWN
,
25 INSTANCE_ATTR_NO_NEW_PRIVS
,
28 INSTANCE_ATTR_SECCOMP
,
29 INSTANCE_ATTR_PIDFILE
,
30 INSTANCE_ATTR_RELOADSIG
,
31 INSTANCE_ATTR_TERMTIMEOUT
,
32 INSTANCE_ATTR_FACILITY
,
36 static const struct blobmsg_policy instance_attr
[__INSTANCE_ATTR_MAX
] = {
37 [INSTANCE_ATTR_COMMAND
] = { "command", BLOBMSG_TYPE_ARRAY
},
38 [INSTANCE_ATTR_ENV
] = { "env", BLOBMSG_TYPE_TABLE
},
39 [INSTANCE_ATTR_DATA
] = { "data", BLOBMSG_TYPE_TABLE
},
40 [INSTANCE_ATTR_NETDEV
] = { "netdev", BLOBMSG_TYPE_ARRAY
},
41 [INSTANCE_ATTR_FILE
] = { "file", BLOBMSG_TYPE_ARRAY
},
42 [INSTANCE_ATTR_TRIGGER
] = { "triggers", BLOBMSG_TYPE_ARRAY
},
43 [INSTANCE_ATTR_RESPAWN
] = { "respawn", BLOBMSG_TYPE_ARRAY
},
44 [INSTANCE_ATTR_NICE
] = { "nice", BLOBMSG_TYPE_INT32
},
45 [INSTANCE_ATTR_LIMITS
] = { "limits", BLOBMSG_TYPE_TABLE
},
46 [INSTANCE_ATTR_WATCH
] = { "watch", BLOBMSG_TYPE_ARRAY
},
47 [INSTANCE_ATTR_ERROR
] = { "error", BLOBMSG_TYPE_ARRAY
},
48 [INSTANCE_ATTR_USER
] = { "user", BLOBMSG_TYPE_STRING
},
49 [INSTANCE_ATTR_GROUP
] = { "group", BLOBMSG_TYPE_STRING
},
50 [INSTANCE_ATTR_STDOUT
] = { "stdout", BLOBMSG_TYPE_BOOL
},
51 [INSTANCE_ATTR_STDERR
] = { "stderr", BLOBMSG_TYPE_BOOL
},
52 [INSTANCE_ATTR_NO_NEW_PRIVS
] = { "no_new_privs", BLOBMSG_TYPE_BOOL
},
53 [INSTANCE_ATTR_JAIL
] = { "jail", BLOBMSG_TYPE_TABLE
},
54 [INSTANCE_ATTR_TRACE
] = { "trace", BLOBMSG_TYPE_BOOL
},
55 [INSTANCE_ATTR_SECCOMP
] = { "seccomp", BLOBMSG_TYPE_STRING
},
56 [INSTANCE_ATTR_PIDFILE
] = { "pidfile", BLOBMSG_TYPE_STRING
},
57 [INSTANCE_ATTR_RELOADSIG
] = { "reload_signal", BLOBMSG_TYPE_INT32
},
58 [INSTANCE_ATTR_TERMTIMEOUT
] = { "term_timeout", BLOBMSG_TYPE_INT32
},
59 [INSTANCE_ATTR_FACILITY
] = { "facility", BLOBMSG_TYPE_STRING
},
62 static void test_blobmsg_procd_instance(const char *filename
)
68 char buf
[BUF_LEN
+1] = { 0 };
69 struct blob_attr
*tb
[__INSTANCE_ATTR_MAX
];
70 const char *fname
= basename((char *) filename
);
72 fd
= fopen(filename
, "r");
74 fprintf(stderr
, "unable to open %s\n", fname
);
78 len
= fread(&buf
, 1, BUF_LEN
, fd
);
81 r
= blobmsg_parse(instance_attr
, __INSTANCE_ATTR_MAX
, tb
, buf
, len
);
85 if (!tb
[INSTANCE_ATTR_COMMAND
] || !tb
[INSTANCE_ATTR_NICE
] || !tb
[INSTANCE_ATTR_STDERR
])
88 if (!blobmsg_check_attr_list(tb
[INSTANCE_ATTR_COMMAND
], BLOBMSG_TYPE_STRING
))
91 if (blobmsg_get_u32(tb
[INSTANCE_ATTR_NICE
]) != 19)
94 if (!blobmsg_get_bool(tb
[INSTANCE_ATTR_STDERR
]))
97 fprintf(stderr
, "%s: OK\n", fname
);
100 int main(int argc
, char *argv
[])
103 fprintf(stderr
, "Usage: %s <blobmsg.bin>\n", argv
[0]);
107 test_blobmsg_procd_instance(argv
[1]);