hal/hald hald_conf.c, NONE, 1.1 hald_conf.h, NONE, 1.1 Makefile.am, 1.24, 1.25 hald.c, 1.6, 1.7

David Zeuthen david at pdx.freedesktop.org
Tue Jun 1 11:47:26 PDT 2004


Update of /cvs/hal/hal/hald
In directory pdx:/tmp/cvs-serv28960/hald

Modified Files:
	Makefile.am hald.c 
Added Files:
	hald_conf.c hald_conf.h 
Log Message:
2004-06-01  David Zeuthen  <david at fubar.dk>

	* hald/hald_conf.[ch]: New files, vendor and user specific
	configuration of the HAL daemon

	* hald/Makefile.am (hald_SOURCES): Add hald_conf.[ch]

	* hald/linux/block_class_device.c (block_class_pre_process): Set
	storage.media_check_enabled and storage.automount_enabled to
	default value from HaldConf. Forgot to set volume.is_mounted to
	FALSE when building the device. NOTE: when media_check_enabled is
	set to FALSE use touch /dev/sda (or whatever) to force a poll for
	media. So, now to write a /etc/hal/hald.conf configuration file
	parser :-)
	(cdrom_check): Set storage.cdrom.eject_check_enabled to default
	value from HaldConf
	(detect_media): Disable continous printing of error when no medium
	is in storage device. Respect the storage.media_check_enabled and
	storage.cdrom.eject_check_enabled properties

	* hald/hald.c (main): Remove opt_run_as



--- NEW FILE: hald_conf.c ---
/***************************************************************************
 * CVSID: $Id: hald_conf.c,v 1.1 2004/06/01 18:47:23 david Exp $
 *
 * device_store.c : Search for .fdi files and merge on match
 *
 * Copyright (C) 2003 David Zeuthen, <david at fubar.dk>
 *
 * Licensed under the Academic Free License version 2.0
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 **************************************************************************/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <expat.h>
#include <assert.h>

#include "hald_conf.h"

static HaldConf hald_conf = {
	TRUE, /* storage.media_check_enabled */
	TRUE, /* storage.automount_enabled */
	TRUE  /* storage.cdrom.eject_check_enabled */
};

HaldConf* 
hald_get_conf (void)
{
	return &hald_conf;
}

--- NEW FILE: hald_conf.h ---
/***************************************************************************
 * CVSID: $Id: hald_conf.h,v 1.1 2004/06/01 18:47:23 david Exp $
 *
 * hald_conf.h : Global configuration for hal daemon
 *
 * Copyright (C) 2004 David Zeuthen, <david at fubar.dk>
 *
 * Licensed under the Academic Free License version 2.0
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 **************************************************************************/

#ifndef HALD_CONF_H
#define HALD_CONF_H

#include <stdarg.h>
#include <stdint.h>
#include <dbus/dbus.h>

typedef struct _HaldConf HaldConf;

/** Configuration of policies for the HAL daemon.
 */
struct _HaldConf {
	/** Default value for storage.media_check_enabled for devices
	 *  of capability storage - this can be overridden by .fdi
	 *  files.
	 *
	 *  Setting this to FALSE results a whitelist policy,
	 *  e.g. media check is only enabled for storage devices with
	 *  a .fdi file saying so.
	 *
	 *  Conversely, setting it to TRUE results in a blacklist
	 *  policy where media check is enabled by default but may be
	 *  overridden by a .fdi for devices causing trouble.
	 *
	 *  Default value is TRUE, this may be overridden in hald.conf.
	 */
	dbus_bool_t storage_media_check_enabled;

	/** Default value for storage.automount_enabled for devices of
	 *  capability storage - this can be overridden by .fdi files.
	 *
	 *  Setting this to FALSE results a whitelist policy,
	 *  e.g. policy agents should only automount storage devices with
	 *  a .fdi file saying so.
	 *
	 *  Conversely, setting it to TRUE results in a blacklist
	 *  policy where policy agents should always automount unless
	 *  this is explicitly overridden by .fdi for devices
	 *  causing trouble.
	 *
	 *  Default value is TRUE, this may be overridden in hald.conf.
	 */
	dbus_bool_t storage_automount_enabled;

	/** Default value for storage.cdrom.eject_check_enabled for
	 *  devices of capability storage - this can be overridden by
	 *  .fdi files.
	 *
	 *  Setting this to FALSE results a whitelist policy,
	 *  e.g. the eject button is only checked if this property is
	 *  overridden in a .fdi file.
	 *
	 *  Conversely, setting it to TRUE results in a blacklist
	 *  policy where the eject button is always checked unless
	 *  this is explicitly overridden by .fdi file for devices
	 *  causing trouble.
	 *
	 *  Default value is TRUE, this may be overridden in hald.conf.
	 */
	dbus_bool_t storage_cdrom_eject_check_enabled;
};

HaldConf* hald_get_conf (void);

#endif  /* HALD_CONF_H */

Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/Makefile.am,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- a/Makefile.am	25 May 2004 20:09:29 -0000	1.24
+++ b/Makefile.am	1 Jun 2004 18:47:23 -0000	1.25
@@ -24,7 +24,8 @@
 	hald_dbus.h			hald_dbus.c			\
 	logger.h			logger.c			\
 	osspec.h							\
-	property.h			property.c
+	property.h			property.c                      \
+	hald_conf.h                     hald_conf.c
 
 hald_SOURCES +=	\
 	linux/common.h			linux/common.c			\

Index: hald.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- a/hald.c	27 Apr 2004 19:05:26 -0000	1.6
+++ b/hald.c	1 Jun 2004 18:47:23 -0000	1.7
@@ -161,9 +161,6 @@
 /** If #TRUE, we will daemonize */
 static dbus_bool_t opt_become_daemon = TRUE;
 
-/** Run as specified username if not #NULL */
-static char *opt_run_as = NULL;
-
 /** Entry point for HAL daemon
  *
  *  @param  argc                Number of arguments
@@ -269,35 +266,6 @@
 		setsid ();
 	}
 
-	if (opt_run_as != NULL) {
-		uid_t uid;
-		gid_t gid;
-		struct passwd *pw;
-
-
-		if ((pw = getpwnam (opt_run_as)) == NULL) {
-			HAL_ERROR (("Could not lookup user %s, errno=%d",
-				    opt_run_as, errno));
-			exit (1);
-		}
-
-		uid = pw->pw_uid;
-		gid = pw->pw_gid;
-
-		if (setgid (gid) < 0) {
-			HAL_ERROR (("Failed to set GID to %d, errno=%d",
-				    gid, errno));
-			exit (1);
-		}
-
-		if (setuid (uid) < 0) {
-			HAL_ERROR (("Failed to set UID to %d, errno=%d",
-				    uid, errno));
-			exit (1);
-		}
-
-	}
-
 	g_type_init ();
 
 	/* set up the dbus services */





More information about the hal-commit mailing list