if (ret == 0) {
struct timeval tv[2];
if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0)
- fchown(dest_desc, (__uid_t) - 1, sb.st_gid);
+ if(fchown(dest_desc, (__uid_t) - 1, sb.st_gid) != 0)
+ log_error("Failed to chown %s: %m", dst);
tv[0].tv_sec = sb.st_atime;
tv[0].tv_usec = 0;
tv[1].tv_sec = sb.st_mtime;
{
int ret = 0;
- _cleanup_free_ char *buf = malloc(LINE_MAX);
+ _cleanup_free_ char *buf = NULL;
size_t linesize = LINE_MAX;
_cleanup_pclose_ FILE *fptr = NULL;
_cleanup_free_ char *cmd = NULL;
+ buf = malloc(LINE_MAX);
+ if (buf == NULL)
+ return -errno;
+
if (strstr(src, ".so") == 0) {
_cleanup_close_ int fd = -1;
fd = open(src, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return -errno;
- read(fd, buf, LINE_MAX);
+ ret = read(fd, buf, LINE_MAX);
+ if (ret == -1)
+ return -errno;
+
buf[LINE_MAX - 1] = '\0';
if (buf[0] == '#' && buf[1] == '!') {
/* we have a shebang */
fptr = popen(cmd, "r");
while (!feof(fptr)) {
- char *p, *q;
+ char *p;
if (getline(&buf, &linesize, fptr) <= 0)
continue;
p = strchr(p, '/');
if (p) {
+ char *q;
+
for (q = p; *q && *q != ' ' && *q != '\n'; q++) ;
*q = '\0';
}
fprintf(f, "%s\n", path);
-
}
static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst)
int ret = 0;
if (strchr(src, '/') == NULL) {
- char **q = NULL;
char **p = find_binary(src);
if (p) {
+ char **q = NULL;
STRV_FOREACH(q, p) {
char *newsrc = *q;
log_debug("dracut_install '%s' '%s'", newsrc, dst);
log_debug("Handle '%s'", argv[i]);
if (strchr(argv[i], '/') == NULL) {
- char **q = NULL;
char **p = find_binary(argv[i]);
if (p) {
+ char **q = NULL;
STRV_FOREACH(q, p) {
char *newsrc = *q;
log_debug("dracut_install '%s'", newsrc);
static int write_to_console(
int level,
const char*file,
- int line,
+ unsigned int line,
const char *func,
const char *buffer) {
- char location[64];
struct iovec iovec[5];
unsigned n = 0;
IOVEC_SET_STRING(iovec[n++], "dracut-install: ");
if (show_location) {
- snprintf(location, sizeof(location), "(%s:%u) ", file, line);
+ char location[64];
+ if (snprintf(location, sizeof(location), "(%s:%u) ", file, line) <= 0)
+ return -errno;
IOVEC_SET_STRING(iovec[n++], location);
}
#define _cleanup_strv_free_ _cleanup_(strv_freep)
char **strv_copy(char * const *l);
-unsigned strv_length(char * const *l) _pure_;
+unsigned int strv_length(char * const *l) _pure_;
char **strv_merge(char **a, char **b);
char **strv_merge_concat(char **a, char **b, const char *suffix);