util/Error: new error passing library
Replaces GLib's GError.
This commit is contained in:
@@ -21,9 +21,10 @@
|
||||
#include "ClientFile.hxx"
|
||||
#include "Client.hxx"
|
||||
#include "protocol/Ack.hxx"
|
||||
#include "io_error.h"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@@ -32,14 +33,13 @@
|
||||
|
||||
bool
|
||||
client_allow_file(const Client *client, const Path &path_fs,
|
||||
GError **error_r)
|
||||
Error &error)
|
||||
{
|
||||
#ifdef WIN32
|
||||
(void)client;
|
||||
(void)path_fs;
|
||||
|
||||
g_set_error(error_r, ack_quark(), ACK_ERROR_PERMISSION,
|
||||
"Access denied");
|
||||
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
|
||||
return false;
|
||||
#else
|
||||
const int uid = client_get_uid(client);
|
||||
@@ -50,21 +50,19 @@ client_allow_file(const Client *client, const Path &path_fs,
|
||||
|
||||
if (uid <= 0) {
|
||||
/* unauthenticated client */
|
||||
g_set_error(error_r, ack_quark(), ACK_ERROR_PERMISSION,
|
||||
"Access denied");
|
||||
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
struct stat st;
|
||||
if (!StatFile(path_fs, st)) {
|
||||
set_error_errno(error_r);
|
||||
error.SetErrno();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (st.st_uid != (uid_t)uid && (st.st_mode & 0444) != 0444) {
|
||||
/* client is not owner */
|
||||
g_set_error(error_r, ack_quark(), ACK_ERROR_PERMISSION,
|
||||
"Access denied");
|
||||
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user