summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2011-03-15 19:47:02 +0100
committerKarel Klic <kklic@redhat.com>2011-03-15 19:47:02 +0100
commitc3d3da9b729542a2b9c75237878693e956ef7896 (patch)
tree5cfb3cbdb43223031c67aeb653e2f263f3bd55d6 /src/lib
parente1bb00559e0b4a77aa7c1c5ae96fd06a79ab3d27 (diff)
parent92ab44176a7702533b4ab065af9745781c51c5bb (diff)
downloadabrt-c3d3da9b729542a2b9c75237878693e956ef7896.tar.gz
abrt-c3d3da9b729542a2b9c75237878693e956ef7896.tar.xz
abrt-c3d3da9b729542a2b9c75237878693e956ef7896.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/abrt_dbus.c2
-rw-r--r--src/lib/dump_dir.c49
-rw-r--r--src/lib/event_config.c20
-rw-r--r--src/lib/event_xml_parser.c20
-rw-r--r--src/lib/steal_directory.c18
5 files changed, 105 insertions, 4 deletions
diff --git a/src/lib/abrt_dbus.c b/src/lib/abrt_dbus.c
index 5d8d861d..a4bab15f 100644
--- a/src/lib/abrt_dbus.c
+++ b/src/lib/abrt_dbus.c
@@ -777,7 +777,7 @@ static DBusMessage* send_get_reply_and_unref(DBusMessage* msg)
{
error_msg_and_die("dbus Warning message: arguments mismatch");
}
- log(">! %s\n", warning_msg);
+ log(">! %s", warning_msg);
}
else
if (tp == DBUS_MESSAGE_TYPE_METHOD_RETURN
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
index d0b1d478..fefec608 100644
--- a/src/lib/dump_dir.c
+++ b/src/lib/dump_dir.c
@@ -491,6 +491,53 @@ void dd_create_basic_files(struct dump_dir *dd, uid_t uid)
free(release);
}
+void dd_sanitize_mode_and_owner(struct dump_dir *dd)
+{
+ /* Don't sanitize if we aren't run under root:
+ * we assume that during file creation (by whatever means,
+ * even by "hostname >file" in abrt_event.conf)
+ * normal umask-based mode setting takes care of correct mode,
+ * and uid:gid is, of course, set to user's uid and gid.
+ *
+ * For root operating on /var/spool/abrt/USERS_PROBLEM, this isn't true:
+ * "hostname >file", for example, would create file OWNED BY ROOT!
+ * This routine resets mode and uid:gid for all such files.
+ */
+ if (dd->dd_uid == (uid_t)-1)
+ return;
+
+ if (!dd->locked)
+ error_msg_and_die("dump_dir is not opened"); /* bug */
+
+ DIR *d = opendir(dd->dd_dirname);
+ if (!d)
+ return;
+
+ struct dirent *dent;
+ while ((dent = readdir(d)) != NULL)
+ {
+ if (dent->d_name[0] == '.') /* ".lock", ".", ".."? skip */
+ continue;
+ char *full_path = concat_path_file(dd->dd_dirname, dent->d_name);
+ struct stat statbuf;
+ if (lstat(full_path, &statbuf) == 0 && S_ISREG(statbuf.st_mode))
+ {
+ if ((statbuf.st_mode & 0777) != 0640)
+ chmod(full_path, 0640);
+ if (statbuf.st_uid != dd->dd_uid || statbuf.st_gid != dd->dd_gid)
+ {
+ if (chown(full_path, dd->dd_uid, dd->dd_gid) != 0)
+ {
+ perror_msg("can't change '%s' ownership to %lu:%lu", full_path,
+ (long)dd->dd_uid, (long)dd->dd_gid);
+ }
+ }
+ }
+ free(full_path);
+ }
+ closedir(d);
+}
+
static int delete_file_dir(const char *dir, bool skip_lock_file)
{
DIR *d = opendir(dir);
@@ -615,7 +662,7 @@ static char *load_text_file(const char *path, unsigned flags)
static bool save_binary_file(const char *path, const char* data, unsigned size, uid_t uid, gid_t gid)
{
- /* "Why 0640?!" See ::Create() for security analysis */
+ /* "Why 0640?!" See dd_create() for security analysis */
unlink(path);
int fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, 0640);
if (fd < 0)
diff --git a/src/lib/event_config.c b/src/lib/event_config.c
index 5532710a..6207f721 100644
--- a/src/lib/event_config.c
+++ b/src/lib/event_config.c
@@ -1,3 +1,21 @@
+/*
+ Copyright (C) 2011 ABRT Team
+ Copyright (C) 2011 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it 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.
+
+ This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
#include "abrtlib.h"
GHashTable *g_event_config_list;
@@ -48,7 +66,7 @@ static int cmp_event_option_name_with_string(gconstpointer a, gconstpointer b)
event_option_t *get_event_option_from_list(const char *name, GList *options)
{
GList *elem = g_list_find_custom(options, name, &cmp_event_option_name_with_string);
- if(elem)
+ if (elem)
return (event_option_t *)elem->data;
return NULL;
}
diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c
index f24606e0..9277aea4 100644
--- a/src/lib/event_xml_parser.c
+++ b/src/lib/event_xml_parser.c
@@ -1,3 +1,21 @@
+/*
+ Copyright (C) 2011 ABRT Team
+ Copyright (C) 2011 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it 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.
+
+ This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
#include "abrtlib.h"
#include "event_config.h"
@@ -79,7 +97,7 @@ static void start_element(GMarkupParseContext *context,
gpointer user_data,
GError **error)
{
- //g_print("start: %s\n", element_name);
+ //log("start: %s", element_name);
struct my_parse_data *parse_data = user_data;
diff --git a/src/lib/steal_directory.c b/src/lib/steal_directory.c
index a77861ee..6676a5fa 100644
--- a/src/lib/steal_directory.c
+++ b/src/lib/steal_directory.c
@@ -1,3 +1,21 @@
+/*
+ Copyright (C) 2011 ABRT Team
+ Copyright (C) 2011 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it 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.
+
+ This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
#include "abrtlib.h"
struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name)