random-seed.c revision 49e942b2bc9fdedba79cd266a076ce9c9d91fc13
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "log.h"
#include "util.h"
#include "mkdir.h"
#define POOL_SIZE_MIN 512
int ret = EXIT_FAILURE;
void* buf;
ssize_t r;
FILE *f;
if (argc != 2) {
log_error("This program requires one argument.");
return EXIT_FAILURE;
}
log_open();
umask(0022);
/* Read pool size, if possible */
/* poolsize is in bits on 2.6, but we want bytes */
buf_size /= 8;
}
fclose(f);
}
if (buf_size <= POOL_SIZE_MIN)
log_error("Failed to allocate buffer.");
goto finish;
}
goto finish;
}
/* When we load the seed we read it and write it to the device
* and then immediately update the saved seed with new data,
* to make sure the next boot gets seeded differently. */
log_error("Failed to open random seed: %m");
goto finish;
}
}
goto finish;
}
}
if (r != 0)
log_error("Failed to read seed file: %m");
} else {
}
log_error("Failed to open random seed: %m");
goto finish;
}
goto finish;
}
} else {
goto finish;
}
/* This is just a safety measure. Given that we are root and
* most likely created the file ourselves the mode and owner
* should be correct anyway. */
else {
}
ret = EXIT_SUCCESS;
if (random_fd >= 0)
if (seed_fd >= 0)
return ret;
}