summaryrefslogtreecommitdiffstats
path: root/include/fileutils.h
Commit message (Collapse)AuthorAgeFilesLines
* lib/fileutils: add xreaddir()Karel Zak2019-04-111-0/+15
| | | | | | | Remove duplicate code and keep only one implementation in include/fileutils.h. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add and use openat build conditionalsRuediger Meier2016-03-071-0/+2
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: move fopen_at() to fileutils.h, remove at.hRuediger Meier2016-03-071-0/+10
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: provide fallback if mkostemp(3) missingRuediger Meier2016-02-291-0/+2
| | | | | | | It's missing on OSX. CC: Yuriy M. Kaminskiy <yumkam@gmail.com> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* include/fileutils: add is_same_inode() checkSami Kerola2015-11-221-0/+12
| | | | | | | Check if a file descriptor and path or stat structure are represent the same file. This function is needed for TACTOU avoidance. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chsh, chfn, vipw: fix filenames collisionKarel Zak2015-08-241-3/+3
| | | | | | | | | | | | | | | | | | The utils when compiled WITHOUT libuser then mkostemp()ing "/etc/%s.XXXXXX" where the filename prefix is argv[0] basename. An attacker could repeatedly execute the util with modified argv[0] and after many many attempts mkostemp() may generate suffix which makes sense. The result maybe temporary file with name like rc.status ld.so.preload or krb5.keytab, etc. Note that distros usually use libuser based ch{sh,fn} or stuff from shadow-utils. It's probably very minor security bug. Addresses: CVE-2015-5224 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: Add new dup_fd_cloexec functionGuillem Jover2015-06-081-0/+1
| | | | | | | | This function duplicates and marks a file descriptor as close-on-exec. Takes care of build and run-time support for the fcntl F_DUPFD_CLOEXEC command, and other errors. Signed-off-by: Guillem Jover <guillem@hadrons.org>
* libmount: add new libmnt_monitor APIKarel Zak2014-12-051-0/+6
| | | | | | | | | | | | It's usually enough to us [e]poll() to monitor kernel mount table, but there is no way how to monitor changes in userspace mount options (e.g. _netdev). The management of these mount options is completely hidden in libmount and /rub/mount/utab is private libmount file. This patch introduces new libmnt_mount API to monitor also userspace mount table. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: xalloc stuff in library-like codeKarel Zak2014-06-181-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: add stripoff_last_component() from libmountKarel Zak2014-06-091-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: add mkdir_p() from libmountKarel Zak2014-06-091-0/+2
|
* include/fileutils: use O_CLOEXEC for mktemp stuffKarel Zak2013-04-031-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fileutils: xmkstemp() interface changeDave Reisner2012-06-021-3/+3
| | | | | | | | | | | We can not let the user control where TMPDIR is for this tempfile. This will be where we write the updated passwd file, and must be capable of being moved atomically with rename(2). Therefore, it cannot be on a different device, or setpwnam() and vipw/vigr programs will invariably fail with EXDEV. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/fileutils: add get_fd_tabsize()Karel Zak2012-04-231-1/+4
| | | | | | as a fallback for the function getdtablesize() Signed-off-by: Karel Zak <kzak@redhat.com>
* fileutils: differentiate xmkstemp and xfmkstempSami Kerola2012-03-181-1/+15
| | | | | | | | | | | | Let developer to choose, case by case, what sort of return value is best in her code. The xmkstemp() is for users who want file descriptor as return value of the function, xfmkstemp() will return FILE pointer. Proposed-By: Karel Zak <kzak@redhat.com> CC: Davidlohr Bueso <dave@gnu.org> Reference: http://marc.info/?l=util-linux-ng&m=133129570124003&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib: add fileutils function collectionSami Kerola2012-03-181-0/+6
The fileutils contains xmkstemp function will create temporary file safe and reusable manner. Reference: http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO.html#TEMPORARY-FILES CC: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Sami Kerola <kerolasa@iki.fi>