X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=d9d525e8a51215eedcb815d5f6c8de924602faae;hb=6073b6f26ab9fc6bf335faa7073ec443eef093fd;hp=e23069c016837ea1cde76d01dbd60cf3d0c8e382;hpb=7f0d207d2c816e0a8cb2742b0a789911f7c99356;p=elogind.git diff --git a/src/shared/util.h b/src/shared/util.h index e23069c01..d9d525e8a 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -93,6 +93,12 @@ #define COMMENTS "#;" #define GLOB_CHARS "*?[" +/* What characters are special in the shell? */ +/* must be escaped outside and inside double-quotes */ +#define SHELL_NEED_ESCAPE "\"\\`$" +/* can be escaped or double-quoted */ +#define SHELL_NEED_QUOTES SHELL_NEED_ESCAPE GLOB_CHARS "'()<>|&;" + #define FORMAT_BYTES_MAX 8 #define ANSI_HIGHLIGHT_ON "\x1B[1;39m" @@ -382,7 +388,8 @@ bool fstype_is_network(const char *fstype); int chvt(int vt); int read_one_char(FILE *f, char *ret, usec_t timeout, bool *need_nl); -int ask(char *ret, const char *replies, const char *text, ...) _printf_(3, 4); +int ask_char(char *ret, const char *replies, const char *text, ...) _printf_(3, 4); +int ask_string(char **ret, const char *text, ...) _printf_(2, 3); int reset_terminal_fd(int fd, bool switch_to_text); int reset_terminal(const char *name); @@ -492,6 +499,7 @@ noreturn void freeze(void); bool null_or_empty(struct stat *st) _pure_; int null_or_empty_path(const char *fn); +int null_or_empty_fd(int fd); DIR *xopendirat(int dirfd, const char *name, int flags); @@ -692,7 +700,7 @@ _alloc_(2, 3) static inline void *memdup_multiply(const void *p, size_t a, size_ bool filename_is_safe(const char *p) _pure_; bool path_is_safe(const char *p) _pure_; bool string_is_safe(const char *p) _pure_; -bool string_has_cc(const char *p) _pure_; +bool string_has_cc(const char *p, const char *ok) _pure_; /** * Check if a string contains any glob patterns. @@ -963,3 +971,5 @@ char *tempfn_xxxxxx(const char *p); char *tempfn_random(const char *p); bool is_localhost(const char *hostname); + +int take_password_lock(const char *root);