1 /* common stuff for cgi-fcgi-interp and prefork-interp */
3 * Copyright 2016-2022 Ian Jackson and contributors to chiark-utils
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 * There is NO WARRANTY.
21 #include <sys/types.h>
23 #include <sys/utsname.h>
24 #include <sys/socket.h>
35 #include <nettle/sha.h>
38 #include "timespeccmp.h"
42 extern const char *interp, *ident, *script, *socket_path, *lock_path;
44 extern struct sha256_ctx identsc;
45 extern const char *run_base;
47 extern const char our_name[];
49 bool find_run_base_var_run(void);
50 void find_socket_path(void);
52 int acquire_lock(void);
53 int flock_file(const char *lock_path);
55 extern const struct cmdinfo cmdinfos[];
56 #define PREFORK_CMDINFOS \
57 { "help", 0, .call=of_help }, \
58 { 0, 'g', 1, .sassignto= &ident }, \
59 { 0, 'G', 1, .call= off_ident_addstring }, \
60 { 0, 'E', 1, .call= off_ident_addenv },
62 void process_opts(const char *const **argv_io);
64 void vmsgcore(int estatus, int errnoval, const char *fmt, va_list al);
66 #define DEF_MSG(func, attrs, estatus, errnoval, after) \
67 static void func(const char *fmt, ...) \
68 __attribute__((unused, format(printf,1,2))) attrs; \
69 static void func(const char *fmt, ...) { \
72 vmsgcore(estatus,errnoval,fmt,al); \
76 DEF_MSG(warninge, /*empty*/, 0, errno, { });
77 DEF_MSG(warning , /*empty*/, 0, -1, { });
79 #define DEF_DIE(func, errnoval) \
80 DEF_MSG(func, __attribute__((noreturn)), 127, errnoval, { abort(); })
87 void fusagemessage(FILE *f);
88 void usagemessage(void);
89 void of_help(const struct cmdinfo *ci, const char *val);
90 void of_iassign(const struct cmdinfo *ci, const char *val);
91 void ident_addinit(void);
92 bool stabs_same_inode(struct stat *a, struct stat *b);
93 void ident_addstring(char key, const char *string);
95 void off_ident_addstring(const struct cmdinfo *ci, const char *name);
96 void off_ident_addenv(const struct cmdinfo *ci, const char *name);
98 void ident_add_key_byte(char key);
100 #define IDENT_ADD_OBJ(key, obj) do{ \
101 ident_add_key_byte(key); \
102 sha256_update(&identsc, sizeof((obj)), (void*)&obj); \