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>
41 extern const char *interp, *ident, *script, *socket_path, *lock_path;
43 extern struct sha256_ctx identsc;
44 extern const char *run_base;
46 extern const char our_name[];
48 bool find_run_base_var_run(void);
49 void find_socket_path(void);
51 int acquire_lock(void);
52 int flock_file(const char *lock_path);
54 extern const struct cmdinfo cmdinfos[];
55 #define PREFORK_CMDINFOS \
56 { "help", 0, .call=of_help }, \
57 { 0, 'g', 1, .sassignto= &ident }, \
58 { 0, 'G', 1, .call= off_ident_addstring }, \
59 { 0, 'E', 1, .call= off_ident_addenv },
61 void process_opts(const char *const **argv_io);
63 void vmsgcore(int estatus, int errnoval, const char *fmt, va_list al);
65 #define DEF_MSG(func, attrs, estatus, errnoval, after) \
66 static void func(const char *fmt, ...) \
67 __attribute__((unused, format(printf,1,2))) attrs; \
68 static void func(const char *fmt, ...) { \
71 vmsgcore(estatus,errnoval,fmt,al); \
75 DEF_MSG(warninge, /*empty*/, 0, errno, { });
76 DEF_MSG(warning , /*empty*/, 0, -1, { });
78 #define DEF_DIE(func, errnoval) \
79 DEF_MSG(func, __attribute__((noreturn)), 127, errnoval, { abort(); })
86 void fusagemessage(FILE *f);
87 void usagemessage(void);
88 void of_help(const struct cmdinfo *ci, const char *val);
89 void of_iassign(const struct cmdinfo *ci, const char *val);
90 void ident_addinit(void);
91 bool stabs_same_inode(struct stat *a, struct stat *b);
92 void ident_addstring(char key, const char *string);
94 void off_ident_addstring(const struct cmdinfo *ci, const char *name);
95 void off_ident_addenv(const struct cmdinfo *ci, const char *name);
97 void ident_add_key_byte(char key);
99 #define IDENT_ADD_OBJ(key, obj) do{ \
100 ident_add_key_byte(key); \
101 sha256_update(&identsc, sizeof((obj)), (void*)&obj); \