char path[MAXPATHLEN];
struct lxc_handler *handler = utmp_data->handler;
+ if (snprintf(path, MAXPATHLEN, "/proc/%d/root/run/utmp",
+ handler->pid) > MAXPATHLEN) {
+ ERROR("path is too long");
+ return -1;
+ }
+
+ if (!access(path, F_OK) && !utmpxname(path))
+ goto utmp_ok;
+
if (snprintf(path, MAXPATHLEN, "/proc/%d/root/var/run/utmp",
handler->pid) > MAXPATHLEN) {
ERROR("path is too long");
return -1;
}
+utmp_ok:
+
setutxent();
while ((utmpx = getutxent())) {
struct lxc_handler *handler)
{
char path[MAXPATHLEN];
+ char path2[MAXPATHLEN];
int fd, wd;
struct lxc_utmp *utmp_data;
struct lxc_conf *conf = handler->conf;
* in utmp at the moment, but want to watch for delete and create
* events as well.
*/
+ if (snprintf(path, MAXPATHLEN, "/proc/%d/root/run",
+ handler->pid) > MAXPATHLEN) {
+ ERROR("path is too long");
+ return -1;
+ }
+ if (snprintf(path2, MAXPATHLEN, "/proc/%d/root/run/utmp",
+ handler->pid) > MAXPATHLEN) {
+ ERROR("path is too long");
+ return -1;
+ }
+ if (!access(path2, F_OK))
+ goto run_ok;
+
if (snprintf(path, MAXPATHLEN, "/proc/%d/root/var/run",
handler->pid) > MAXPATHLEN) {
ERROR("path is too long");
return 0;
}
+run_ok:
+
utmp_data = (struct lxc_utmp *)malloc(sizeof(struct lxc_utmp));
if (NULL == utmp_data) {