diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2015-08-12 12:41:44 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-09-07 18:21:55 +0200 |
commit | 5b71bd7da12503792a481b1599bfcf9415b1014f (patch) | |
tree | 55152e12c4e049d1dbad900add91fe0dcc22d1f9 /src/util/util.h | |
parent | 6a5abcaf3eb6133bc96c44a11e423fe7a0dca3a6 (diff) | |
download | sssd-5b71bd7da12503792a481b1599bfcf9415b1014f.tar.gz sssd-5b71bd7da12503792a481b1599bfcf9415b1014f.tar.xz sssd-5b71bd7da12503792a481b1599bfcf9415b1014f.zip |
UTIL: Provide a common interface to safely create temporary files
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/util/util.h')
-rw-r--r-- | src/util/util.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/util.h b/src/util/util.h index 3d90cf0d1..ecbed1c98 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -653,4 +653,25 @@ int get_seuser(TALLOC_CTX *mem_ctx, const char *login_name, /* convert time from generalized form to unix time */ errno_t sss_utc_to_time_t(const char *str, const char *format, time_t *unix_time); +/* Creates a unique file using mkstemp with provided umask. The template + * must end with XXXXXX. Returns the fd, sets _err to an errno value on error. + * + * Prefer using sss_unique_file() as it uses a secure umask internally. + */ +int sss_unique_file_ex(TALLOC_CTX *mem_ctx, + char *path_tmpl, + mode_t file_umask, + errno_t *_err); +int sss_unique_file(TALLOC_CTX *owner, + char *path_tmpl, + errno_t *_err); + +/* Creates a unique filename using mkstemp with secure umask. The template + * must end with XXXXXX + * + * path_tmpl must be a talloc context. Destructor would be set on the filename + * so that it's guaranteed the file is removed. + */ +int sss_unique_filename(TALLOC_CTX *owner, char *path_tmpl); + #endif /* __SSSD_UTIL_H__ */ |