TLS: move from SUPPORT_TLS to DISABLE_TLS macro for the build
[exim.git] / src / src / functions.h
index 4193caccbd2c3f9e0d4c3b6587ea9fe1f0137bcf..11fb8b59e7a33a098d6fde1b8364e9b4b3e654ea 100644 (file)
@@ -10,6 +10,8 @@
 to avoid having a lot of tiddly little headers with only a couple of lines in
 them. However, some functions that are used (or not used) by utility programs
 are in in fact in separate headers. */
+#ifndef _FUNCTIONS_H_
+#define _FUNCTIONS_H_
 
 
 #ifdef EXIM_PERL
@@ -20,7 +22,7 @@ extern uschar *init_perl(uschar *);
 #endif
 
 
-#ifdef SUPPORT_TLS
+#ifndef DISABLE_TLS
 extern const char *
                std_dh_prime_default(void);
 extern const char *
@@ -49,6 +51,7 @@ extern BOOL    tls_client_start(client_conn_ctx *, smtp_connect_args *,
 
 extern void    tls_close(void *, int);
 extern BOOL    tls_could_read(void);
+extern void    tls_daemon_init(void);
 extern int     tls_export_cert(uschar *, size_t, void *);
 extern int     tls_feof(void);
 extern int     tls_ferror(void);
@@ -74,7 +77,7 @@ extern BOOL    tls_is_name_for_cert(const uschar *, void *);
 extern int     tlsa_lookup(const host_item *, dns_answer *, BOOL);
 # endif
 
-#endif /*SUPPORT_TLS*/
+#endif /*DISABLE_TLS*/
 
 
 /* Everything else... */
@@ -209,6 +212,8 @@ extern BOOL    enq_start(uschar *, unsigned);
 extern uschar *event_raise(uschar *, const uschar *, uschar *);
 extern void    msg_event_raise(const uschar *, const address_item *);
 #endif
+
+extern int     exim_chown_failure(int, const uschar*, uid_t, gid_t);
 extern const uschar * exim_errstr(int);
 extern void    exim_exit(int, const uschar *);
 extern void    exim_nullstd(void);
@@ -345,7 +350,7 @@ extern uschar *parse_message_id(uschar *, uschar **, uschar **);
 extern const uschar *parse_quote_2047(const uschar *, int, uschar *, uschar *, int, BOOL);
 extern uschar *parse_date_time(uschar *str, time_t *t);
 extern int     vaguely_random_number(int);
-#ifdef SUPPORT_TLS
+#ifndef DISABLE_TLS
 extern int     vaguely_random_number_fallback(int);
 #endif
 
@@ -586,6 +591,42 @@ extern BOOL    write_chunk(transport_ctx *, uschar *, int);
 extern ssize_t write_to_fd_buf(int, const uschar *, size_t);
 
 
+#if !defined(MACRO_PREDEF) && !defined(COMPILE_UTILITY)
+/* exim_chown - in some NFSv4 setups *seemes* to be an issue with
+chown(<exim-uid>, <exim-gid>).
+
+Probably because the idmapping is broken, misconfigured or set up in
+an unusal way. (see Bug 2931). As I'm not sure, if this was a single
+case of misconfiguration, or if there are more such broken systems
+out, I try to impose as least impact as possible and for now just write
+a panic log entry pointing to the bug report. You're encouraged to
+contact the developers, if you experience this issue.
+
+fd     the file descriptor (or -1 if not valid)
+name   the file name for error messages or for file operations,
+  if fd is < 0
+owner  the owner
+group  the group
+
+returns 0 on success, -1 on failure */
+
+static inline int
+exim_fchown(int fd, uid_t owner, gid_t group, const uschar *name)
+{
+return fchown(fd, owner, group)
+  ? exim_chown_failure(fd, name, owner, group) : 0;
+}
+
+static inline int
+exim_chown(const uschar *name, uid_t owner, gid_t group)
+{
+return chown(CCS name, owner, group)
+  ? exim_chown_failure(-1, name, owner, group) : 0;
+}
+#endif /* !MACRO_PREDEF */
+
+#endif  /* _FUNCTIONS_H_ */
+
 /* vi: aw
 */
 /* End of functions.h */