2002-01-19 21:58:41 +01:00
|
|
|
/* sysutils.h - System utility functions for Gnupg
|
|
|
|
* Copyright (C) 2002 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
Change license for some files in common to LGPLv3+/GPLv2+.
Having the LGPL on the common GnuPG code helps to share code
between GnuPG and related projects (like GPGME and Libassuan). This
is good for interoperability and to reduces bugs.
* common/asshelp.c, common/asshelp.h, common/asshelp2.c, common/b64dec.c
* common/b64enc.c, common/convert.c, common/dns-cert.c
* common/dns-cert.h common/exechelp-posix.c, common/exechelp-w32.c
* common/exechelp-w32ce.c, common/exechelp.h, common/get-passphrase.c
* common/get-passphrase.h, common/gettime.c, common/gpgrlhelp.c
* common/helpfile.c, common/homedir.c, common/http.c, common/http.h
* common/i18n.c, common/init.c, common/init.h, common/iobuf.c
* common/iobuf.h, common/localename.c, common/membuf.c, common/membuf.h
* common/miscellaneous.c, common/openpgp-oid.c, common/openpgpdefs.h
* common/percent.c, common/pka.c, common/pka.h, common/session-env.c
* common/session-env.h, common/sexp-parse.h, common/sexputil.c
* common/signal.c, common/srv.c, common/srv.h, common/ssh-utils.c
* common/ssh-utils.h, common/sysutils.c, common/sysutils.h
* common/tlv.c, common/tlv.h, common/ttyio.c, common/ttyio.h
* common/userids.c, common/userids.h, common/xasprintf.c: Change
license to LGPLv3+/GPLv2+/
2012-04-20 15:43:06 +02:00
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of either
|
2002-01-19 21:58:41 +01:00
|
|
|
*
|
Change license for some files in common to LGPLv3+/GPLv2+.
Having the LGPL on the common GnuPG code helps to share code
between GnuPG and related projects (like GPGME and Libassuan). This
is good for interoperability and to reduces bugs.
* common/asshelp.c, common/asshelp.h, common/asshelp2.c, common/b64dec.c
* common/b64enc.c, common/convert.c, common/dns-cert.c
* common/dns-cert.h common/exechelp-posix.c, common/exechelp-w32.c
* common/exechelp-w32ce.c, common/exechelp.h, common/get-passphrase.c
* common/get-passphrase.h, common/gettime.c, common/gpgrlhelp.c
* common/helpfile.c, common/homedir.c, common/http.c, common/http.h
* common/i18n.c, common/init.c, common/init.h, common/iobuf.c
* common/iobuf.h, common/localename.c, common/membuf.c, common/membuf.h
* common/miscellaneous.c, common/openpgp-oid.c, common/openpgpdefs.h
* common/percent.c, common/pka.c, common/pka.h, common/session-env.c
* common/session-env.h, common/sexp-parse.h, common/sexputil.c
* common/signal.c, common/srv.c, common/srv.h, common/ssh-utils.c
* common/ssh-utils.h, common/sysutils.c, common/sysutils.h
* common/tlv.c, common/tlv.h, common/ttyio.c, common/ttyio.h
* common/userids.c, common/userids.h, common/xasprintf.c: Change
license to LGPLv3+/GPLv2+/
2012-04-20 15:43:06 +02:00
|
|
|
* - the GNU Lesser General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 3 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* or
|
|
|
|
*
|
|
|
|
* - the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* or both in parallel, as here.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
2002-01-19 21:58:41 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2002-01-19 21:58:41 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNUPG_COMMON_SYSUTILS_H
|
|
|
|
#define GNUPG_COMMON_SYSUTILS_H
|
|
|
|
|
2007-07-12 17:28:30 +02:00
|
|
|
/* Because we use system handles and not libc low level file
|
|
|
|
descriptors on W32, we need to declare them as HANDLE (which
|
|
|
|
actually is a plain pointer). This is required to eventually
|
|
|
|
support 64 bits Windows systems. */
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
typedef void *gnupg_fd_t;
|
|
|
|
#define GNUPG_INVALID_FD ((void*)(-1))
|
2007-10-01 16:48:39 +02:00
|
|
|
#define INT2FD(s) ((void *)(s))
|
|
|
|
#define FD2INT(h) ((unsigned int)(h))
|
2007-07-12 17:28:30 +02:00
|
|
|
#else
|
|
|
|
typedef int gnupg_fd_t;
|
|
|
|
#define GNUPG_INVALID_FD (-1)
|
2007-10-01 16:48:39 +02:00
|
|
|
#define INT2FD(s) (s)
|
|
|
|
#define FD2INT(h) (h)
|
2007-07-12 17:28:30 +02:00
|
|
|
#endif
|
|
|
|
|
2020-10-20 16:38:06 +02:00
|
|
|
#ifdef HAVE_STAT
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif
|
2007-07-12 17:28:30 +02:00
|
|
|
|
2020-10-21 16:59:38 +02:00
|
|
|
struct gnupg_dir_s;
|
|
|
|
typedef struct gnupg_dir_s *gnupg_dir_t;
|
|
|
|
struct gnupg_dirent_s
|
|
|
|
{
|
|
|
|
/* We don't have a d_ino because that can't be used on Windows
|
|
|
|
* anyway. D_NAME is a pointer into the gnupg_dir_s which has a
|
|
|
|
* static buffer or allocates sufficient space as needed. This is
|
|
|
|
* only valid after gnupg_readdir. */
|
|
|
|
char *d_name;
|
|
|
|
};
|
|
|
|
typedef struct gnupg_dirent_s *gnupg_dirent_t;
|
|
|
|
|
|
|
|
|
2002-01-19 21:58:41 +01:00
|
|
|
void trap_unaligned (void);
|
|
|
|
int disable_core_dumps (void);
|
2004-05-11 11:54:52 +02:00
|
|
|
int enable_core_dumps (void);
|
2016-11-29 16:18:24 +01:00
|
|
|
void enable_special_filenames (void);
|
2002-01-19 21:58:41 +01:00
|
|
|
const unsigned char *get_session_marker (size_t *rlen);
|
2011-04-12 16:30:08 +02:00
|
|
|
unsigned int get_uint_nonce (void);
|
2007-06-26 15:48:44 +02:00
|
|
|
/*int check_permissions (const char *path,int extension,int checkonly);*/
|
2007-06-20 13:16:42 +02:00
|
|
|
void gnupg_sleep (unsigned int seconds);
|
2016-10-31 12:20:33 +01:00
|
|
|
void gnupg_usleep (unsigned int usecs);
|
2007-07-12 17:28:30 +02:00
|
|
|
int translate_sys2libc_fd (gnupg_fd_t fd, int for_write);
|
|
|
|
int translate_sys2libc_fd_int (int fd, int for_write);
|
2016-11-29 16:18:24 +01:00
|
|
|
int check_special_filename (const char *fname, int for_write, int notranslate);
|
2007-08-22 12:55:07 +02:00
|
|
|
FILE *gnupg_tmpfile (void);
|
2007-12-03 14:05:15 +01:00
|
|
|
void gnupg_reopen_std (const char *pgmname);
|
2020-01-13 15:20:49 +01:00
|
|
|
void gnupg_inhibit_set_foregound_window (int yes);
|
2008-02-14 20:50:10 +01:00
|
|
|
void gnupg_allow_set_foregound_window (pid_t pid);
|
2010-03-24 13:15:30 +01:00
|
|
|
int gnupg_remove (const char *fname);
|
2016-11-16 17:43:59 +01:00
|
|
|
gpg_error_t gnupg_rename_file (const char *oldname, const char *newname,
|
|
|
|
int *block_signals);
|
2017-07-25 12:24:01 +02:00
|
|
|
int gnupg_mkdir (const char *name, const char *modestr);
|
|
|
|
int gnupg_chdir (const char *name);
|
2021-08-11 11:50:41 +02:00
|
|
|
int gnupg_rmdir (const char *name);
|
2016-04-20 14:55:45 +02:00
|
|
|
int gnupg_chmod (const char *name, const char *modestr);
|
2014-11-11 15:14:31 +01:00
|
|
|
char *gnupg_mkdtemp (char *template);
|
2010-04-14 13:24:02 +02:00
|
|
|
int gnupg_setenv (const char *name, const char *value, int overwrite);
|
|
|
|
int gnupg_unsetenv (const char *name);
|
2014-04-15 16:40:48 +02:00
|
|
|
char *gnupg_getcwd (void);
|
2020-10-20 10:43:55 +02:00
|
|
|
gpg_err_code_t gnupg_access (const char *name, int mode);
|
2020-10-20 16:38:06 +02:00
|
|
|
#ifdef HAVE_STAT
|
|
|
|
int gnupg_stat (const char *name, struct stat *statbuf);
|
|
|
|
#endif /*HAVE_STAT*/
|
2020-10-20 14:08:35 +02:00
|
|
|
int gnupg_open (const char *name, int flags, unsigned int mode);
|
2020-10-21 16:59:38 +02:00
|
|
|
|
|
|
|
gnupg_dir_t gnupg_opendir (const char *name);
|
|
|
|
gnupg_dirent_t gnupg_readdir (gnupg_dir_t gdir);
|
|
|
|
int gnupg_closedir (gnupg_dir_t gdir);
|
|
|
|
|
2020-08-06 15:21:31 +02:00
|
|
|
gpg_error_t gnupg_chuid (const char *user, int silent);
|
2016-10-26 22:37:07 +02:00
|
|
|
char *gnupg_get_socket_name (int fd);
|
2017-02-08 13:49:41 +01:00
|
|
|
int gnupg_fd_valid (int fd);
|
2002-01-19 21:58:41 +01:00
|
|
|
|
2017-06-23 13:20:42 +02:00
|
|
|
gpg_error_t gnupg_inotify_watch_delete_self (int *r_fd, const char *fname);
|
2016-10-15 21:35:05 +02:00
|
|
|
gpg_error_t gnupg_inotify_watch_socket (int *r_fd, const char *socket_name);
|
|
|
|
int gnupg_inotify_has_name (int fd, const char *name);
|
|
|
|
|
|
|
|
|
2004-12-15 15:15:54 +01:00
|
|
|
#ifdef HAVE_W32_SYSTEM
|
2021-01-11 14:19:06 +01:00
|
|
|
void gnupg_w32_set_errno (int ec);
|
2014-03-07 09:46:44 +01:00
|
|
|
void *w32_get_user_sid (void);
|
2004-12-20 17:17:25 +01:00
|
|
|
|
2010-03-10 13:24:58 +01:00
|
|
|
#include "../common/w32help.h"
|
2004-12-20 17:17:25 +01:00
|
|
|
|
2004-12-15 15:15:54 +01:00
|
|
|
#endif /*HAVE_W32_SYSTEM*/
|
2002-01-19 21:58:41 +01:00
|
|
|
|
|
|
|
#endif /*GNUPG_COMMON_SYSUTILS_H*/
|