mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Merge with git+ssh://pasky/srv/git/elinks.git
This commit is contained in:
commit
d160a9993e
@ -618,6 +618,22 @@ typedef int (some_func_T)(void *);
|
||||
typedef long long our_long_T;
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Please use mode_t and S_I???? macros instead of numeric modes
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.Use:
|
||||
-------------------------------------------------------------------------------
|
||||
mode_t mode = S_IRWXU | S_IRGRP | S_IROTH;
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
.Instead of:
|
||||
-------------------------------------------------------------------------------
|
||||
int mode = 0744;
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Note that S_IREAD, S_IWRITE and S_IEXEC are obsolete, you should use S_IRUSR,
|
||||
S_IWUSR, S_IXUSR instead.
|
||||
|
||||
|
||||
Patches
|
||||
~~~~~~~
|
||||
|
@ -321,7 +321,7 @@ save_input_history(struct input_history *history, unsigned char *filename)
|
||||
history_file = straconcat(elinks_home, filename, NULL);
|
||||
if (!history_file) return -1;
|
||||
|
||||
ssi = secure_open(history_file, 0177);
|
||||
ssi = secure_open(history_file);
|
||||
mem_free(history_file);
|
||||
if (!ssi) return -1;
|
||||
|
||||
|
@ -94,7 +94,7 @@ bookmarks_write(struct list_head *bookmarks_list)
|
||||
file_name = straconcat(elinks_home, file_name, NULL);
|
||||
if (!file_name) return;
|
||||
|
||||
ssi = secure_open(file_name, 0177);
|
||||
ssi = secure_open(file_name);
|
||||
mem_free(file_name);
|
||||
if (!ssi) return;
|
||||
|
||||
|
@ -805,7 +805,7 @@ write_config_file(unsigned char *prefix, unsigned char *name,
|
||||
config_file = straconcat(prefix, slash, name, NULL);
|
||||
if (!config_file) goto free_cfg_str;
|
||||
|
||||
ssi = secure_open(config_file, 0177);
|
||||
ssi = secure_open(config_file);
|
||||
if (ssi) {
|
||||
secure_fputs(ssi, cfg_str);
|
||||
ret = secure_close(ssi);
|
||||
|
@ -775,7 +775,7 @@ save_cookies(void) {
|
||||
cookfile = straconcat(elinks_home, COOKIES_FILENAME, NULL);
|
||||
if (!cookfile) return;
|
||||
|
||||
ssi = secure_open(cookfile, 0177); /* rw for user only */
|
||||
ssi = secure_open(cookfile);
|
||||
mem_free(cookfile);
|
||||
if (!ssi) return;
|
||||
|
||||
|
@ -225,7 +225,7 @@ save_formhist_to_file(void)
|
||||
file = straconcat(elinks_home, FORMS_HISTORY_FILENAME, NULL);
|
||||
if (!file) return 0;
|
||||
|
||||
ssi = secure_open(file, 0177);
|
||||
ssi = secure_open(file);
|
||||
mem_free(file);
|
||||
if (!ssi) return 0;
|
||||
|
||||
|
@ -369,7 +369,7 @@ write_global_history(void)
|
||||
file_name = straconcat(elinks_home, GLOBAL_HISTORY_FILENAME, NULL);
|
||||
if (!file_name) return;
|
||||
|
||||
ssi = secure_open(file_name, 0177); /* rw for user only */
|
||||
ssi = secure_open(file_name);
|
||||
mem_free(file_name);
|
||||
if (!ssi) return;
|
||||
|
||||
|
@ -371,7 +371,7 @@ elinks_usleep(unsigned long useconds)
|
||||
static int
|
||||
bind_to_af_unix(void)
|
||||
{
|
||||
mode_t saved_mask = umask(0177);
|
||||
mode_t saved_mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
|
||||
int attempts = 0;
|
||||
int pf = get_address(&s_info_listen, ADDR_IP_SERVER);
|
||||
|
||||
|
@ -10,6 +10,15 @@
|
||||
#endif
|
||||
|
||||
/* File permission flags not available on win32 systems. */
|
||||
#ifndef S_IRUSR
|
||||
#define S_IRUSR 0000400 /* R for user */
|
||||
#endif
|
||||
#ifndef S_IWUSR
|
||||
#define S_IWUSR 0000200 /* W for user */
|
||||
#endif
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR 0000100 /* X for user */
|
||||
#endif
|
||||
#ifndef S_ISUID
|
||||
#define S_ISUID 0004000 /* set user id on execution */
|
||||
#endif
|
||||
@ -38,4 +47,14 @@
|
||||
#define S_ISVTX 0001000 /* save swapped text even after use */
|
||||
#endif
|
||||
|
||||
#ifndef S_IRWXU
|
||||
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
|
||||
#endif
|
||||
#ifndef S_IRWXG
|
||||
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
||||
#endif
|
||||
#ifndef S_IRWXO
|
||||
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
||||
#endif
|
||||
|
||||
#endif /* EL__OSDEP_STAT_H */
|
||||
|
@ -657,14 +657,14 @@ open_bittorrent_file(struct bittorrent_meta *meta, struct bittorrent_file *file,
|
||||
|
||||
if (!name) return -1;
|
||||
|
||||
fd = open(name, flags, S_IREAD | S_IWRITE);
|
||||
fd = open(name, flags, S_IRUSR | S_IWUSR);
|
||||
if (fd == -1) {
|
||||
/* 99% of the time the file will already exist so special case
|
||||
* the directory and file creation. */
|
||||
if (errno == ENOENT
|
||||
&& trans == BITTORRENT_WRITE
|
||||
&& create_bittorrent_path(name) == BITTORRENT_STATE_OK)
|
||||
fd = open(name, flags | O_CREAT, S_IREAD | S_IWRITE);
|
||||
fd = open(name, flags | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
}
|
||||
|
||||
mem_free(name);
|
||||
|
@ -299,7 +299,7 @@ execute_cgi(struct connection *conn)
|
||||
scriptlen = strlen(script);
|
||||
|
||||
if (stat(script, &buf) || !(S_ISREG(buf.st_mode))
|
||||
|| !(buf.st_mode & S_IEXEC)) {
|
||||
|| !(buf.st_mode & S_IXUSR)) {
|
||||
mem_free(script);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1034,7 +1034,7 @@ display_dir_entry(struct cache_entry *cached, off_t *pos, int *tries,
|
||||
add_char_to_string(&string, ftp_info->type);
|
||||
|
||||
if (ftp_info->permissions) {
|
||||
int p = ftp_info->permissions;
|
||||
mode_t p = ftp_info->permissions;
|
||||
|
||||
#define FTP_PERM(perms, buffer, flag, index, id) \
|
||||
if ((perms) & (flag)) (buffer)[(index)] = (id);
|
||||
|
@ -138,7 +138,7 @@ enum ftp_unix {
|
||||
static int
|
||||
parse_ftp_unix_permissions(const unsigned char *src, int len)
|
||||
{
|
||||
int perms = 0;
|
||||
mode_t perms = 0;
|
||||
|
||||
if (len != 9
|
||||
&& !(len == 10 && src[9] == '+')) /* ACL tag */
|
||||
@ -583,12 +583,12 @@ parse_ftp_winnt_response(struct ftp_file_info *info, unsigned char *src, int len
|
||||
|
||||
if (*src == '<') {
|
||||
info->type = FTP_FILE_DIRECTORY;
|
||||
info->permissions = 0755;
|
||||
info->permissions = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||
|
||||
} else if (isdigit(*src)) {
|
||||
info->type = FTP_FILE_PLAINFILE;
|
||||
info->size = parse_ftp_number(&src, end, 0, LONG_MAX);
|
||||
info->permissions = 0644;
|
||||
info->permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
|
||||
} else {
|
||||
info->type = FTP_FILE_UNKNOWN;
|
||||
|
@ -22,7 +22,7 @@ struct ftp_file_info {
|
||||
long size; /* File size. -1 if unknown. */
|
||||
time_t mtime; /* Modification time */
|
||||
unsigned int local_time_zone:1; /* What format the mtime is in */
|
||||
int permissions; /* File permissions */
|
||||
mode_t permissions; /* File permissions */
|
||||
};
|
||||
|
||||
#define FTP_SIZE_UNKNOWN -1
|
||||
@ -30,10 +30,10 @@ struct ftp_file_info {
|
||||
/* File info initializers: */
|
||||
|
||||
#define INIT_FTP_FILE_INFO \
|
||||
{ FTP_FILE_UNKNOWN, INIT_STRING("", 0), INIT_STRING("", 0), FTP_SIZE_UNKNOWN, 0, 0, 0644 }
|
||||
{ FTP_FILE_UNKNOWN, INIT_STRING("", 0), INIT_STRING("", 0), FTP_SIZE_UNKNOWN, 0, 0, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH }
|
||||
|
||||
#define INIT_FTP_FILE_INFO_ROOT \
|
||||
{ FTP_FILE_DIRECTORY, INIT_STRING("..", 2), INIT_STRING("", 0), FTP_SIZE_UNKNOWN, 0, 0, 0755 }
|
||||
{ FTP_FILE_DIRECTORY, INIT_STRING("..", 2), INIT_STRING("", 0), FTP_SIZE_UNKNOWN, 0, 0, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH }
|
||||
|
||||
struct ftp_file_info *
|
||||
parse_ftp_file_info(struct ftp_file_info *info, unsigned char *src, int len);
|
||||
|
@ -272,7 +272,7 @@ file_read_line(unsigned char *line, size_t *size, FILE *file, int *lineno)
|
||||
int
|
||||
safe_mkstemp(unsigned char *template)
|
||||
{
|
||||
mode_t saved_mask = umask(0177);
|
||||
mode_t saved_mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
|
||||
int fd = mkstemp(template);
|
||||
|
||||
umask(saved_mask);
|
||||
@ -321,12 +321,12 @@ stat_mode(struct string *string, struct stat *stp)
|
||||
unsigned char rwx[10] = "---------";
|
||||
|
||||
if (stp) {
|
||||
int mode = stp->st_mode;
|
||||
int shift;
|
||||
mode_t mode = stp->st_mode;
|
||||
unsigned int shift;
|
||||
|
||||
/* Set permissions attributes for user, group and other */
|
||||
for (shift = 0; shift <= 6; shift += 3) {
|
||||
int m = mode << shift;
|
||||
mode_t m = mode << shift;
|
||||
|
||||
if (m & S_IRUSR) rwx[shift + 0] = 'r';
|
||||
if (m & S_IWUSR) rwx[shift + 1] = 'w';
|
||||
@ -607,7 +607,7 @@ mkalldirs(const unsigned char *path)
|
||||
|
||||
p[pos] = 0;
|
||||
|
||||
ret = mkdir(p, S_IREAD | S_IWRITE | S_IEXEC);
|
||||
ret = mkdir(p, S_IRWXU);
|
||||
|
||||
p[pos] = separator;
|
||||
|
||||
|
@ -68,8 +68,8 @@ enum secsave_errno secsave_errno = SS_ERR_NONE;
|
||||
|
||||
/* Open a file for writing in a secure way. It returns a pointer to a structure
|
||||
* secure_save_info on success, or NULL on failure. */
|
||||
struct secure_save_info *
|
||||
secure_open(unsigned char *file_name, mode_t mask)
|
||||
static struct secure_save_info *
|
||||
secure_open_umask(unsigned char *file_name, mode_t mask)
|
||||
{
|
||||
mode_t saved_mask;
|
||||
struct stat st;
|
||||
@ -203,6 +203,11 @@ end:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct secure_save_info *
|
||||
secure_open(unsigned char *file_name)
|
||||
{
|
||||
return secure_open_umask(file_name, S_IXUSR | S_IRWXG | S_IRWXO);
|
||||
}
|
||||
|
||||
/* Close a file opened with secure_open, and return 0 on success, errno
|
||||
* or -1 on failure. */
|
||||
|
@ -31,7 +31,8 @@ struct secure_save_info {
|
||||
int secure_save; /* use secure save for this file */
|
||||
};
|
||||
|
||||
struct secure_save_info *secure_open(unsigned char *, mode_t);
|
||||
struct secure_save_info *secure_open(unsigned char *);
|
||||
|
||||
int secure_close(struct secure_save_info *);
|
||||
|
||||
int secure_fputs(struct secure_save_info *, const char *);
|
||||
|
Loading…
Reference in New Issue
Block a user