1 /* safe path traversal functions for 'patch' */
2 
3 /* Copyright (C) 2015 Free Software Foundation, Inc.
4 
5    Written by Tim Waugh <twaugh@redhat.com> and
6    Andreas Gruenbacher <agruenba@redhat.com>.
7 
8    This program is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20 
21 #include <stdbool.h>
22 
23 extern bool unsafe;
24 
25 int safe_stat (const char *pathname, struct stat *buf);
26 int safe_lstat (const char *pathname, struct stat *buf);
27 int safe_open (const char *pathname, int flags, mode_t mode);
28 int safe_rename (const char *oldpath, const char *newpath);
29 int safe_mkdir (const char *pathname, mode_t mode);
30 int safe_rmdir (const char *pathname);
31 int safe_unlink (const char *pathname);
32 int safe_symlink (const char *target, const char *linkpath);
33 int safe_chmod (const char *pathname, mode_t mode);
34 int safe_lchown (const char *pathname, uid_t owner, gid_t group);
35 int safe_lutimens (const char *pathname, struct timespec const times[2]);
36 ssize_t safe_readlink(const char *pathname, char *buf, size_t bufsiz);
37 int safe_access(const char *pathname, int mode);
38