/*
* lock_driver_sanlock.c: A lock driver for Sanlock
*
- * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2010-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
goto error;
}
- if (driver->group != -1)
+ if (driver->group != (gid_t) -1)
perms |= 0060;
if ((fd = open(path, O_WRONLY|O_CREAT|O_EXCL, perms)) < 0) {
VIR_DEBUG("Someone else just created lockspace %s", path);
} else {
/* chown() the path to make sure sanlock can access it */
- if ((driver->user != -1 || driver->group != -1) &&
+ if ((driver->user != (uid_t) -1 || driver->group != (gid_t) -1) &&
(fchown(fd, driver->user, driver->group) < 0)) {
virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"),
}
} else if (S_ISREG(st.st_mode)) {
/* okay, the lease file exists. Check the permissions */
- if (((driver->user != -1 && driver->user != st.st_uid) ||
- (driver->group != -1 && driver->group != st.st_gid)) &&
+ if (((driver->user != (uid_t) -1 && driver->user != st.st_uid) ||
+ (driver->group != (gid_t) -1 && driver->group != st.st_gid)) &&
(chown(path, driver->user, driver->group) < 0)) {
virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"),
goto error;
}
- if ((driver->group != -1 && (st.st_mode & 0060) != 0060) &&
+ if ((driver->group != (gid_t) -1 && (st.st_mode & 0060) != 0060) &&
chmod(path, 0660) < 0) {
virReportSystemError(errno,
_("cannot chmod '%s' to 0660"),
driver->requireLeaseForDisks = true;
driver->hostID = 0;
driver->autoDiskLease = false;
- driver->user = driver->group = -1;
+ driver->user = (uid_t) -1;
+ driver->group = (gid_t) -1;
if (!(driver->autoDiskLeasePath = strdup(LOCALSTATEDIR "/lib/libvirt/sanlock"))) {
VIR_FREE(driver);
virReportOOMError();
VIR_DEBUG("Someone else just created lockspace %s", res->disks[0].path);
} else {
/* chown() the path to make sure sanlock can access it */
- if ((driver->user != -1 || driver->group != -1) &&
+ if ((driver->user != (uid_t) -1 || driver->group != (gid_t) -1) &&
(fchown(fd, driver->user, driver->group) < 0)) {
virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"),