[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
PATCH: pyblock: return empty list instead of error when run as non-root
- From: Hans de Goede <hdegoede redhat com>
- To: Discussion of Development and Customization of the Red Hat Linux Installer <anaconda-devel-list redhat com>
- Subject: PATCH: pyblock: return empty list instead of error when run as non-root
- Date: Wed, 29 Oct 2008 17:03:52 +0100
Hi All,
This patch is necessary to run pychecker as non root,
Regards,
Hans
diff -up pyblock-0.32/dm.c~ pyblock-0.32/dm.c
--- pyblock-0.32/dm.c~ 2008-10-24 15:31:33.000000000 +0200
+++ pyblock-0.32/dm.c 2008-10-24 15:31:33.000000000 +0200
@@ -1560,7 +1560,7 @@ pydm_rmpart(PyObject *self, PyObject *ar
static PyObject *
pydm_maps(PyObject *self)
{
- struct dm_task *task;
+ struct dm_task *task = NULL;
struct dm_names *names;
int n;
unsigned int next = 0;
@@ -1571,6 +1571,14 @@ pydm_maps(PyObject *self)
if (!list)
goto out;
+ /* dm_task_create() only works as root for non root use just return an
+ empty list */
+ if (geteuid()) {
+ printf("%s: %d: not running as root returning empty list\n",
+ __FILE__, __LINE__);
+ goto save_list;
+ }
+
task = dm_task_create(DM_DEVICE_LIST);
if (!task) {
if (!PyErr_Occurred()) {
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]