+2020-11-01 Érico N. Rolim <erico.erc@gmail.com>
+
+ * debuginfod-client.c (debuginfod_init_cache): Use ACCESSPERMS for
+ mkdir, DEFFILEMODE for open with O_CREAT.
+
2020-11-01 Érico N. Rolim <erico.erc@gmail.com>
* debuginfod.cxx: include libintl.h.
return 0;
/* Create the cache and config files as necessary. */
- if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
+ if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
return -errno;
int fd = -1;
/* init cleaning interval config file. */
- fd = open(interval_path, O_CREAT | O_RDWR, 0666);
+ fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
if (fd < 0)
return -errno;
/* init max age config file. */
if (stat(maxage_path, &st) != 0
- && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
+ && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
return -errno;
if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+2020-11-01 Érico N. Rolim <erico.erc@gmail.com>
+
+ * system.h (ACCESSPERMS): Define macro if it doesn't exist.
+ (ALLPERMS): Likewise.
+ (DEFFILEMODE): Likewise.
+
2020-06-11 Mark Wielaaard <mark@klomp.org>
* printversion.c (print_version): Update copyright year.
__res; })
#endif
+#ifndef ACCESSPERMS
+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
+#endif
+
+#ifndef ALLPERMS
+#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+#endif
+
+#ifndef DEFFILEMODE
+#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666 */
+#endif
+
static inline ssize_t __attribute__ ((unused))
pwrite_retry (int fd, const void *buf, size_t len, off_t off)
{
+2020-11-01 Érico N. Rolim <erico.erc@gmail.com>
+
+ * unstrip.c (make_directories): Use ACCESSPERMS for mkdir.
+ (handle_file): Use DEFFILEMODE for open with O_CREAT for ET_REL
+ files, ACCESSPERMS otherwise.
+
2020-11-01 Érico N. Rolim <erico.erc@gmail.com>
* Makefile.am (nm_LDADD): Add obstack_LIBS.
if (dir == NULL)
error(EXIT_FAILURE, errno, _("memory exhausted"));
- while (mkdir (dir, 0777) < 0 && errno != EEXIST)
+ while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
{
if (errno == ENOENT)
make_directories (dir);
/* Copy the unstripped file and then modify it. */
int outfd = open (output_file, O_RDWR | O_CREAT,
- stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
+ (stripped_ehdr->e_type == ET_REL
+ ? DEFFILEMODE : ACCESSPERMS));
if (outfd < 0)
error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
+2020-11-01 Érico N. Rolim <erico.erc@gmail.com>
+ Mark Wielaard <mark@klomp.org>
+
+ * alldts.c (main): Use DEFFILEMODE for open with O_CREAT.
+ * arextract.c (main): Likewise.
+ * ecp.c (main): Likewise for creat.
+ * elfstrtab.c (check_elf): Use DEFFILEMODE for open with O_CREAT,
+ remove mode from open calls without O_CREAT.
+ * emptyfile.c (check_elf): Likewise.
+ * fillfile.c (check_elf): Likewise.
+ * vendorelf.c (check_elf): Likewise.
+ * newdata.c (checkelf): Use DEFFILEMODE for open with O_CREAT.
+ * update{1,2,3,4}.c (main): Likewise.
+ *
+
2020-10-31 Mark Wielaard <mark@klomp.org>
* dwfl-proc-attach.c (dlopen): New external function override.
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
int
(void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
/* Open the file. */
- int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %m\n", fname);
}
/* Open the output file. */
- outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, 0666);
+ outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, DEFFILEMODE);
if (outfd == -1)
{
printf ("cannot open output file: %m");
error (EXIT_FAILURE, 0, "problems opening '%s' as ELF file: %s",
argv[1], elf_errmsg (-1));
- int outfd = creat (argv[2], 0666);
+ int outfd = creat (argv[2], DEFFILEMODE);
if (outfd == -1)
error (EXIT_FAILURE, errno, "cannot open output file '%s'", argv[2]);
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
#include ELFUTILS_HEADER(elf)
#include <gelf.h>
printf ("\nfname: %s\n", fname);
stridx = 0;
- int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %s\n", fname, strerror (errno));
close (fd);
/* Read the ELF from disk now. */
- fd = open (fname, O_RDWR, 0666);
+ fd = open (fname, O_RDWR);
if (fd == -1)
{
printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
close (fd);
// And read it in one last time.
- fd = open (fname, O_RDONLY, 0666);
+ fd = open (fname, O_RDONLY);
if (fd == -1)
{
printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
#include ELFUTILS_HEADER(elf)
#include <gelf.h>
printf ("\nfname: %s\n", fname);
stridx = 0; // Reset strtab strings index
- int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %s\n", fname, strerror (errno));
close (fd);
/* Reread the ELF from disk now. */
- fd = open (fname, O_RDWR, 0666);
+ fd = open (fname, O_RDWR);
if (fd == -1)
{
printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
close (fd);
// And read it in one last time.
- fd = open (fname, O_RDONLY, 0666);
+ fd = open (fname, O_RDONLY);
if (fd == -1)
{
printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
#include ELFUTILS_HEADER(elf)
#include <gelf.h>
printf ("\nfname: %s\n", fname);
stridx = 0; // Reset strtab strings index
- int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %s\n", fname, strerror (errno));
/* Reread the ELF from disk now. */
printf ("Rereading %s\n", fname);
- fd = open (fname, O_RDWR, 0666);
+ fd = open (fname, O_RDWR);
if (fd == -1)
{
printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
// And read it in one last time.
printf ("Rereading %s again\n", fname);
- fd = open (fname, O_RDONLY, 0666);
+ fd = open (fname, O_RDONLY);
if (fd == -1)
{
printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
#include ELFUTILS_HEADER(elf)
#include <gelf.h>
printf ("\ncheck_elf: %s\n", fname);
- int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 00666);
+ int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot create `%s': %s\n", fname, strerror (errno));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
int
Elf32_Ehdr *ehdr;
int i;
- fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %s\n", fname, strerror (errno));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
int
Elf32_Phdr *phdr;
int i;
- fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %s\n", fname, strerror (errno));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
#include ELFUTILS_HEADER(dwelf)
Dwelf_Strent *shstrtabse;
int i;
- fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %s\n", fname, strerror (errno));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
#include ELFUTILS_HEADER(dwelf)
Dwelf_Strent *shstrtabse;
int i;
- fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %s\n", fname, strerror (errno));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "system.h"
#include ELFUTILS_HEADER(elf)
#include <gelf.h>
{
printf ("\nfname: %s\n", fname);
- int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
if (fd == -1)
{
printf ("cannot open `%s': %s\n", fname, strerror (errno));
close (fd);
/* Reread the ELF from disk now. */
- fd = open (fname, O_RDONLY, 0666);
+ fd = open (fname, O_RDONLY);
if (fd == -1)
{
printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));