forked from lix-project/lix
Remove tabs
This commit is contained in:
parent
def5160b61
commit
3007f57377
|
@ -279,9 +279,9 @@ static void _computePathSize(const Path & path,
|
||||||
blocks += st.st_blocks;
|
blocks += st.st_blocks;
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
Strings names = readDirectory(path);
|
Strings names = readDirectory(path);
|
||||||
|
|
||||||
for (Strings::iterator i = names.begin(); i != names.end(); ++i)
|
for (Strings::iterator i = names.begin(); i != names.end(); ++i)
|
||||||
_computePathSize(path + "/" + *i, bytes, blocks);
|
_computePathSize(path + "/" + *i, bytes, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,15 +308,15 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed)
|
||||||
bytesFreed += st.st_blocks * 512;
|
bytesFreed += st.st_blocks * 512;
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
Strings names = readDirectory(path);
|
Strings names = readDirectory(path);
|
||||||
|
|
||||||
/* Make the directory writable. */
|
/* Make the directory writable. */
|
||||||
if (!(st.st_mode & S_IWUSR)) {
|
if (!(st.st_mode & S_IWUSR)) {
|
||||||
if (chmod(path.c_str(), st.st_mode | S_IWUSR) == -1)
|
if (chmod(path.c_str(), st.st_mode | S_IWUSR) == -1)
|
||||||
throw SysError(format("making `%1%' writable") % path);
|
throw SysError(format("making `%1%' writable") % path);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Strings::iterator i = names.begin(); i != names.end(); ++i)
|
for (Strings::iterator i = names.begin(); i != names.end(); ++i)
|
||||||
_deletePath(path + "/" + *i, bytesFreed);
|
_deletePath(path + "/" + *i, bytesFreed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,14 +348,14 @@ void makePathReadOnly(const Path & path)
|
||||||
struct stat st = lstat(path);
|
struct stat st = lstat(path);
|
||||||
|
|
||||||
if (!S_ISLNK(st.st_mode) && (st.st_mode & S_IWUSR)) {
|
if (!S_ISLNK(st.st_mode) && (st.st_mode & S_IWUSR)) {
|
||||||
if (chmod(path.c_str(), st.st_mode & ~S_IWUSR) == -1)
|
if (chmod(path.c_str(), st.st_mode & ~S_IWUSR) == -1)
|
||||||
throw SysError(format("making `%1%' read-only") % path);
|
throw SysError(format("making `%1%' read-only") % path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
Strings names = readDirectory(path);
|
Strings names = readDirectory(path);
|
||||||
for (Strings::iterator i = names.begin(); i != names.end(); ++i)
|
for (Strings::iterator i = names.begin(); i != names.end(); ++i)
|
||||||
makePathReadOnly(path + "/" + *i);
|
makePathReadOnly(path + "/" + *i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,22 +380,22 @@ Path createTempDir(const Path & tmpRoot, const Path & prefix,
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
Path tmpDir = tempName(tmpRoot, prefix, includePid, counter);
|
Path tmpDir = tempName(tmpRoot, prefix, includePid, counter);
|
||||||
if (mkdir(tmpDir.c_str(), mode) == 0) {
|
if (mkdir(tmpDir.c_str(), mode) == 0) {
|
||||||
/* Explicitly set the group of the directory. This is to
|
/* Explicitly set the group of the directory. This is to
|
||||||
work around around problems caused by BSD's group
|
work around around problems caused by BSD's group
|
||||||
ownership semantics (directories inherit the group of
|
ownership semantics (directories inherit the group of
|
||||||
the parent). For instance, the group of /tmp on
|
the parent). For instance, the group of /tmp on
|
||||||
FreeBSD is "wheel", so all directories created in /tmp
|
FreeBSD is "wheel", so all directories created in /tmp
|
||||||
will be owned by "wheel"; but if the user is not in
|
will be owned by "wheel"; but if the user is not in
|
||||||
"wheel", then "tar" will fail to unpack archives that
|
"wheel", then "tar" will fail to unpack archives that
|
||||||
have the setgid bit set on directories. */
|
have the setgid bit set on directories. */
|
||||||
if (chown(tmpDir.c_str(), (uid_t) -1, getegid()) != 0)
|
if (chown(tmpDir.c_str(), (uid_t) -1, getegid()) != 0)
|
||||||
throw SysError(format("setting group of directory `%1%'") % tmpDir);
|
throw SysError(format("setting group of directory `%1%'") % tmpDir);
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
}
|
}
|
||||||
if (errno != EEXIST)
|
if (errno != EEXIST)
|
||||||
throw SysError(format("creating directory `%1%'") % tmpDir);
|
throw SysError(format("creating directory `%1%'") % tmpDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,8 +724,8 @@ AutoCloseDir::operator DIR *()
|
||||||
void AutoCloseDir::close()
|
void AutoCloseDir::close()
|
||||||
{
|
{
|
||||||
if (dir) {
|
if (dir) {
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
dir = 0;
|
dir = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -840,12 +840,12 @@ void killUser(uid_t uid)
|
||||||
if (setuid(uid) == -1)
|
if (setuid(uid) == -1)
|
||||||
throw SysError("setting uid");
|
throw SysError("setting uid");
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (kill(-1, SIGKILL) == 0) break;
|
if (kill(-1, SIGKILL) == 0) break;
|
||||||
if (errno == ESRCH) break; /* no more processes */
|
if (errno == ESRCH) break; /* no more processes */
|
||||||
if (errno != EINTR)
|
if (errno != EINTR)
|
||||||
throw SysError(format("cannot kill processes for uid `%1%'") % uid);
|
throw SysError(format("cannot kill processes for uid `%1%'") % uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (std::exception & e) {
|
} catch (std::exception & e) {
|
||||||
writeToStderr((format("killing processes belonging to uid `%1%': %2%\n") % uid % e.what()).str());
|
writeToStderr((format("killing processes belonging to uid `%1%': %2%\n") % uid % e.what()).str());
|
||||||
|
@ -1040,14 +1040,14 @@ string statusToString(int status)
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
return (format("failed with exit code %1%") % WEXITSTATUS(status)).str();
|
return (format("failed with exit code %1%") % WEXITSTATUS(status)).str();
|
||||||
else if (WIFSIGNALED(status)) {
|
else if (WIFSIGNALED(status)) {
|
||||||
int sig = WTERMSIG(status);
|
int sig = WTERMSIG(status);
|
||||||
#if HAVE_STRSIGNAL
|
#if HAVE_STRSIGNAL
|
||||||
const char * description = strsignal(sig);
|
const char * description = strsignal(sig);
|
||||||
return (format("failed due to signal %1% (%2%)") % sig % description).str();
|
return (format("failed due to signal %1% (%2%)") % sig % description).str();
|
||||||
#else
|
#else
|
||||||
return (format("failed due to signal %1%") % sig).str();
|
return (format("failed due to signal %1%") % sig).str();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return "died abnormally";
|
return "died abnormally";
|
||||||
} else return "succeeded";
|
} else return "succeeded";
|
||||||
|
|
Loading…
Reference in a new issue