dpkg 1.22.7-3-g89f48
|
Functions | |
size_t | path_trim_slash_slashdot (char *path) |
Trim ‘/’ and ‘/. | |
const char * | path_skip_slash_dotslash (const char *path) |
Skip ‘/’ and ‘. | |
const char * | path_basename (const char *path) |
Return the last component of a pathname. | |
char * | path_quote_filename (char *dst, const char *src, size_t size) |
Escape characters in a pathname for safe locale printing. | |
char * | path_make_temp_template (const char *suffix) |
Create a template for a temporary pathname. | |
int | secure_unlink_statted (const char *pathname, const struct stat *stab) |
int | secure_unlink (const char *pathname) |
Securely unlink a pathname. | |
int | secure_remove (const char *pathname) |
Securely remove a pathname. | |
void | path_remove_tree (const char *pathname) |
Remove a pathname and anything below it. | |
const char * path_basename | ( | const char * | path | ) |
Return the last component of a pathname.
path | The pathname to get the base name from. |
Referenced by command_init(), and dpkg_set_progname().
char * path_make_temp_template | ( | const char * | suffix | ) |
Create a template for a temporary pathname.
suffix | The suffix to use for the template string. |
References str_fmt().
Referenced by do_build().
char * path_quote_filename | ( | char * | dst, |
const char * | src, | ||
size_t | n | ||
) |
Escape characters in a pathname for safe locale printing.
We need to quote paths so that they do not cause problems when printing them, for example with snprintf(3) which does not work if the format string contains s and an argument has invalid characters for the current locale, it will then return -1.
To simplify things, we just escape all 8 bit characters, instead of just invalid characters.
dst | The escaped destination string. |
src | The source string to escape. |
n | The size of the destination buffer. |
void path_remove_tree | ( | const char * | pathname | ) |
Remove a pathname and anything below it.
This function removes pathname and all its contents recursively.
References _, dbg_eachfile, debug(), internerr, ohshite(), path_skip_slash_dotslash(), RM, secure_unlink(), subproc_fork(), and subproc_reap().
Referenced by cu_cidir(), cu_pathname(), and tarobject().
const char * path_skip_slash_dotslash | ( | const char * | path | ) |
Skip ‘/’ and ‘.
/’ from the beginning of a pathname.
path | The pathname to skip. |
Referenced by dpkg_fsys_get_path(), f_conffiles(), fsys_hash_find_node(), and path_remove_tree().
size_t path_trim_slash_slashdot | ( | char * | path | ) |
Trim ‘/’ and ‘/.
’ from the end of a pathname.
The given string will get NUL-terminatd.
path | The pathname to trim. |
Referenced by dpkg_fsys_set_dir().
int secure_remove | ( | const char * | pathname | ) |
Securely remove a pathname.
This is a secure version of remove(3) using secure_unlink() instead of unlink(2).
0 | On success. |
-1 | On failure, just like unlink(2) & rmdir(2). |
References dbg_eachfiledetail, debug(), and secure_unlink().
Referenced by cu_installnew().
int secure_unlink | ( | const char * | pathname | ) |
Securely unlink a pathname.
If the pathname to remove is:
we change its mode so that a malicious user cannot use it, even if it's linked to another file.
References secure_unlink_statted().
Referenced by path_remove_tree(), and secure_remove().
int secure_unlink_statted | ( | const char * | pathname, |
const struct stat * | stab | ||
) |