1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-11-01 09:21:11 +03:00
Commit Graph

52 Commits

Author SHA1 Message Date
Kay Sievers
c70560feef logging: add trailing newline to all strings 2008-04-20 21:07:06 +02:00
Harald Hoyer
16511863d9 check line length after comment check and whitespace strip 2007-09-11 17:17:29 +02:00
Kay Sievers
9dd0c2573b rename config "filename" to "dir" 2006-12-08 09:48:53 +01:00
Kay Sievers
27b77df44d update source file headers 2006-08-28 00:29:11 +02:00
Kay Sievers
d548032795 better log test and comments
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2006-01-13 13:17:10 +01:00
Kay Sievers
1aa1e24848 replace libsysfs
We never used any of the libsysfs convenience features. Here we replace
it completely with 300 lines of code, which are much simpler and a bit
faster cause udev(d) does not open any syfs file for a simple event which
does not need any parent device information.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2006-01-09 21:18:00 +01:00
Marco d'Itri
2796c47b5c allow to overwrite the configured udev_root by exporting UDEV_ROOT 2005-11-25 18:56:06 +01:00
Kay Sievers
fc55cf68ca remove "udev_db" option from config file
All udev state is kept in /$udev_root/.udev/ now. No option to
configure that anymore, it will always be there.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-11-16 04:14:15 +01:00
Marco d'Itri
ff3e4bed21 add strerror() to error logs 2005-11-07 18:44:18 +01:00
Kay Sievers
b2c6818dc3 rename ...trailing_char() to ...trailing_chars()
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-08-28 23:15:51 +02:00
Kay Sievers
13d11705bf switch some strlcpy's to memcpy
strlcpy counts the sourec string lengt and is therefore not suitable
to copy a defined length of characters from one string to another.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-08-08 02:21:55 +02:00
Kay Sievers
e8d569b414 move code to its own files
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-07-22 12:35:58 -04:00
Kay Sievers
c07669bd66 udev: handle all events - not only class and block devices
Handle all events with rules. If udev is expected to handle hotplug.d/
the exernal helper must be called.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-06-05 15:55:29 +02:00
Kay Sievers
6a522681e1 udev: move dev.d/ handling to external helper
Modern rules are expected to call notification and postprocessing with    
the RUN key. For compatibility the current behavior can be emulated
with an external helper.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-06-05 05:11:29 +02:00
kay.sievers@vrfy.org
821d0ec803 [PATCH] add RUN key to be able to run rule based notification
SUBSYSTEM=="block", RUN="/sbin/program"
  will execute the program only for block device events.

ACTION="remove", SUBSYSTEM=="block", RUN"/sbin/program"
  will execute the program, if a block device is removed.
2005-04-26 23:55:00 -07:00
kay.sievers@vrfy.org
8a4c0c32f4 [PATCH] fix klibc's broken strlcpy/strlcat
udevinfo segfaults cause klibc's strlcpy writes behind the specified
size of the destination string. strlcat truncates the destination
string which is also not what you expect from a concatenation function.
2005-04-26 23:54:59 -07:00
kay.sievers@vrfy.org
18614ab25d [PATCH] remove untrusted chars read from sysfs-values or returned by PROGRAM
Better remove characters that are useless in a device node name.
It may be a security risk to pass any character read from e.g. a
sysfs attribute to a shell script we execute later.
  
Prevent the modification of the libsysfs attribute value
cache.

Clear PROGRAM result if the execution encountered an error.
2005-04-26 23:54:59 -07:00
kay.sievers@vrfy.org
6b493a20e1 [PATCH] support log-priority levels in udev.conf 2005-04-26 23:54:59 -07:00
kay.sievers@vrfy.org
65005a7f81 [PATCH] test-suite: remove UDEV_TEST, it's not needed anymore 2005-04-26 23:54:59 -07:00
kay.sievers@vrfy.org
28ce66de17 [PATCH] support =, ==, !=, += for the key match and assignment 2005-04-26 23:53:17 -07:00
kay.sievers@vrfy.org
e5e322bc62 [PATCH] rename namedev_dev to udev_rule 2005-04-26 23:53:17 -07:00
kay.sievers@vrfy.org
63f61c5cf6 [PATCH] replace strncpy()/strncat() by strlcpy()/strlcat() 2005-04-26 23:51:00 -07:00
kay.sievers@vrfy.org
ddf695023f [PATCH] remove useless warning if udev.conf contains keys not read by udev itself 2005-04-26 23:19:09 -07:00
kay.sievers@vrfy.org
b9a8c4821a [PATCH] remove default_* permissions from udev.conf file
With the "permissions only rules" we can just place:
 
   MODE="0660", OWNER="root", GROUP="root"
 
at the beginning of the rules file and get exactly the same behavior.
If no values are given the compiled-in defaults are used.
2005-04-26 23:19:09 -07:00
kay.sievers@vrfy.org
9f8dfa19cf [PATCH] allow multiline rules by backslash at the end of the line
On Sun, 2004-12-19 at 18:31 +0100, Marco d'Itri wrote:
> > On Dec 19, Kay Sievers <kay.sievers@vrfy.org> wrote:
> 
> > (Feature request: would it be possible to extend the rules files parser
> > to support continuation lines? I'd like it to consider lines starting
> > with white space as part of the previous line.)
> 
> How about the usual backslash at the end of the line. Here is a simple
> patch.
2005-04-26 23:19:09 -07:00
kay.sievers@vrfy.org
4ae6d03f39 [PATCH] simplify rules file by setting default mode to 0660
On Sun, 2004-12-19 at 18:31 +0100, Marco d'Itri wrote:
> It may be better to use default_mode="0660", I do not think that there
> are any mode 600 devices. This would allow setting only the group for
> most of them.
2005-04-26 23:19:09 -07:00
kay.sievers@vrfy.org
8b36cc0f17 [PATCH] complete removal of explicit udev permissions config file 2005-04-26 23:17:47 -07:00
kay.sievers@vrfy.org
5f72c470ad [PATCH] simplify permission handling
Initialize the defaults in udev_config.c instead of namedev.c.
Replace macro by expanded code. Switch to mode_t instead
of string value. Add and clarify some comments.
2005-04-26 23:00:29 -07:00
kay.sievers@vrfy.org
16ac31aaee [PATCH] don't call the hotplug scripts with a test run 2005-04-26 23:00:29 -07:00
kay.sievers@vrfy.org
9af5bb2f8f [PATCH] rename udev_lib to udev_utils and dev_d to udev_multiplex 2005-04-26 22:44:02 -07:00
kay.sievers@vrfy.org
2b41e68a08 [PATCH] replace tdb database by simple lockless file database
This makes the udev operation completely lockless by storing a
file for every node in /dev/.udevdb/* This solved the problem
with deadlocking concurrent udev processes waiting for each other
to release the file lock under heavy load.
2005-04-26 22:16:40 -07:00
kay.sievers@vrfy.org
707680b1cf [PATCH] remove sleeps from udev as it is external now
Here we remove all the sysfs sleep loops from udev as wait_for_sysfs
will do this for us and any other hotplug user. We still keep a small
blacklist of subsystems we don't care about but any missing entry here
will no longer lead to a spinning udev waiting for files.
2005-04-26 22:02:44 -07:00
kay.sievers@vrfy.org
3db7fa2702 [PATCH] fix udev segfaults with bad permissions file
On Tue, Sep 14, 2004 at 02:53:12PM +0200, Loleslaw wrote:
> Hi,
> Since I started using udev-031 on my gentoo udevstart would just segfault
> (udev-030 worked). As it turned out I had a file in /etc/udev/permissions.d
> with a single space in one line. I've cleaned the file and it works all
> right, but I thought you could be interested.
> I've traced it to function namedev_init_permissions in namedev_parse.c
> I don't know C well enough to suggest a patch.

Yeah, thanks for pointing that out. It only happens if the file ends with
whitespace-only lines. Here is a fix and a test for udev-test.pl to
cover that case.
2005-04-26 21:37:01 -07:00
arun@codemovers.org
3e4414508b [PATCH] udev - read long lines from config files overflow fix
Hi Kay,

On 23:12 Sat 04 Sep     , Kay Sievers wrote:
> Cool, a real bug :)
> Thanks, for the patch. I think it would be better to skip lenghth exceeding
> lines instead of cutting it and continue. While looking at it I restructured
> the buffer reading logic a bit and fixed another stupid bug.
Thanks for the cleanup.

You may have overlooked the fix for udev_config.c(parsing udev.conf) in
your patch.  So, I've adapted the fixes you applied to namedev_parse.c
to this file also.

Also, while 'eating' the whitespace the 'count' doesn't get decremented.
This leads strncpy to copy the number of whitespace minus 1 characters
from the next line. Minus 1 because it copies '\n' from the current
line.

		while (isspace(bufline[0])) {
			bufline++;
+			count--;
		}
		.
		.
		.
		strncpy(line, bufline, count);

Included patch(against udev-030) contains the above fixes as well as
your fixes.


Signed-off-by: Arun Bhanu <arun@codemovers.org>
2005-04-26 21:37:00 -07:00
ogasawara@osdl.org
c33359307b [PATCH] evaluate getenv() return value for udev_config.c
Small patch to fix the evaluation logic for the return value of getenv()
in udev_config.c file.  Basically, the actual values for the environment
variables "UDEV_NO_SLEEP" and "UDEV_NO_DEVD" were not being checked.
For example UDEV_NO_SLEEP could have been set to false but the line:

if (getenv("UDEV_NO_SLEEP") != NULL)

in this case would always evaluate to true, since getenv() returns
char*, thus the "udev_sleep" variable would be set incorrectly.  The
patch makes sure to check the value returned by getenv() not just if
getenv() returned a value.  Hope this made sense.  Thanks,
2005-04-26 21:35:47 -07:00
kay.sievers@vrfy.org
aef6bb132e [PATCH] udev default config layout changes
Here we catch up, after the default config changes.

o the man page is updated to reflect the new default config

o /etc/udev/rules.d/ + permissions.d/ dirs are created now

o udev.rules is installed in /etc/udev/rules.d/50-udev.rules
  so the user can easily order the files by prepending a number.
  (RedHat has the same name in the last rpm.)

o defined directory names in the Makefile are all without slashes now,
  not the first half with and the remaining without.

o all binaries are uninstalled now

o leading slashes in config values are now removed or prepended while the
  config is parsed, so we are more robust if the usere changes something.

o replaced the macros from udev_config.c with real code, cause we can
  skip if the value matches and not useless iterate over the remaining
  fields.

o config parsing errors are logged with info() now, fixes the bug where
  we report a error with debug_parse(), even when there isn't one
2005-04-26 21:35:17 -07:00
kay.sievers@vrfy.org
9b28a52a0a [PATCH] DEVPATH for netdev
Here we change the DEVPATH for netdev's in the environment of the dev.d/
scripts to the name the device is renamed to. The original name doesn't
exist in the kernel after rename.
2005-04-26 21:35:13 -07:00
kay.sievers@vrfy.org
bbbe503ec1 [PATCH] netdev - udevdb+dev.d changes
Here is a patch to change the netdev handling in the database and for
the dev.d/ calls. I applies on top of the udevd.patch, cause klibc has
no sysinfo().

 o netdev's are also put into our database now. I want this for the
   udevruler gui to get a list of all handled devices.
   All devices in the db are stamped with the system uptime value at
   the creation time. 'udevinfo -d' prints it.

 o the DEVPATH value is the key for udevdb, but if we rename
   a netdev, the name is replaced in the kernel, so we add
   the changed name to the db to match with the remove event.

   NOTE: The dev.d/ scripts still get the original name from the
   hotplug call. Should we replace DEVPATH with the new name too?

 o We now only add a device to the db, if we have successfully created
   the main node or successfully renamed a netdev. This is the main part
   of the patch, cause I needed to clean the retval passing trough all
   the functions used for node creation.

 o DEVNODE sounds a bit ugly for netdev's so I exported DEVNAME too.
   Can we change the name?

 o I've added a UDEV_NO_DEVD to possibly skip the script execution
   and used it in udev-test.pl.
   udevstart is the same horror now, if you have scripts with logging
   statements in dev.d/ it takes minutes to finish, can we skip the
   scripts here too?

 o The get_device_type() function is changed to be more strict, cause
   'udevinfo -a -p /block/' gets a class device for it and tries to
   print the major/minor values.

 o bugfix, the RESULT value has now a working newline removal and a test
   for this case.
2005-04-26 21:35:13 -07:00
kay.sievers@vrfy.org
c81b35c08b [PATCH] replace fgets() with mmap() and introduce udev_lib.[hc]
Here we replace the various fgets() with a mmap() call for the config
file reading, due to the reported performance problems with klibc.

Thanks to Patrick's testing, it makes a very small, close to nothing
speed gain for libc users, but a 6 times speed increase for klibc users
with a 1000 line config file.

I've created a udev_lib.[hc] for this and also moved all the generic
stuff from udev.h in there and uninlined the functions.
2005-04-26 21:35:10 -07:00
kay.sievers@vrfy.org
17794d77b9 [PATCH] rename strn*() macros to strmax
Hey, I wrote the strn*() macros just 10 days ago and yesterday this trap
caught me with the %c{x} bug.
The names are misleading cause we all expect that the from field is limited by
the size argument, but we actually limit the overall size of the destination
string to prevent a overflow.

Here we rename all strn*() macros to str*max(). That should be
more self-explanatory.
2005-04-26 21:35:08 -07:00
kay.sievers@vrfy.org
831f800da3 [PATCH] udev - safer string handling - part two
As promised, here is the next round. We provide in addition to the
already used macros:

  strfieldcpy(to, from)
  strfieldcat(to, from)

the corresponding friends, if the size of the target is not known and
must be provided by the caller:

  strnfieldcpy(to, from, maxsize)
  strnfieldcat(to, from, maxsize)

and switch nearly all possibly unsafe users of strcat(), strncat(),
strcpy() and strncpy() to these safer macros.

The last known remaining issue seems the use of sprintf() and
snprintf(). I will take on it later today or tomorrow.
2005-04-26 21:32:30 -07:00
greg@kroah.com
c80da5085f [PATCH] force udev to include the internal version of libsysfs and never the external one.
Should fix some more build bugs...
2005-04-26 21:32:29 -07:00
patmans@us.ibm.com
0bad3406c1 [PATCH] udev use new libsysfs header file location
Use the new location of libsysfs header files.
2005-04-26 21:32:29 -07:00
greg@kroah.com
961e47847c [PATCH] add support for UDEV_NO_SLEEP env variable so Gentoo people will be happy.
Actually, I'm happy to, startup time is much smaller...
2005-04-26 21:32:28 -07:00
greg@kroah.com
51a8bb2f36 [PATCH] fix log option code so that it actually works for all udev programs.
Also introduce boolean type for config file to use.
2005-04-26 21:32:26 -07:00
azarah@nosferatu.za.org
4d803d8d04 [PATCH] make logging a config option
Once again, patch to make logging a config option.

Reason for this (since you asked for it):
 - In our setup it is easy (although still annoying) .. just edit the
   ebuild, add logging support (or remove it) and rebuild.  For say a
   binary distro, having the logging is useful for debugging some
   times, but its more a once of, or rare thing, as you do not add or
   change config files every day.  Sure, we can have logging by
   default, but many do not want ~300 lines of extra debugging in their
   logs is not pleasant, and they will complain.  Rebuilding the
   package for that binary package (given the users it is targeted to)
   is usually not within most users grasp.
2005-04-26 21:32:26 -07:00
greg@kroah.com
274812b502 [PATCH] move get_pair to udev_config.c because udevinfo doesn't need all of namedev.o 2005-04-26 21:13:19 -07:00
kay.sievers@vrfy.org
765cbd9759 [PATCH] set default owner/group in db - update
I've edited the man page today, so this is alreay included :)

Also a few more trivials:
  o added the defaults to udev.conf.in
  o removed class_dev from get_default_mode(), to match with Hanna's
  o changed size of mode_str to MODE_SIZE
  o changed a few char compares from from 0x00 to '\0'
2005-04-26 21:13:17 -07:00
hannal@us.ibm.com
74c73ef994 [PATCH] set default owner/group in db.
This patch fixes a bug where the udev database stored empty strings
for Owner and Group if they were default. This patch stores the default
value into the database if not set otherwise. See example output:


crw-------    1 root     root       4,  65 Jan 16 11:13 ttyS1

P: /class/tty/ttyS1
N: ttyS1
S:
O: root
G: root

This is a bit of a hack. However, until udev supports setting the
o/g values they will be root/root anyway so the database might as
well reflect the truth instead of empty strings.
2005-04-26 21:13:17 -07:00
kay.sievers@vrfy.org
54988802b7 [PATCH] add udev logging to info log
On Thu, Jan 15, 2004 at 05:14:16AM +0100, Kay Sievers wrote:
> On Wed, Jan 14, 2004 at 01:10:43PM -0800, Greg KH wrote:
> > On Wed, Jan 14, 2004 at 02:34:26PM -0600, Clay Haapala wrote:
> > > On Wed, 14 Jan 2004, Chris Friesen spake thusly:
> > > >
> > > > Maybe for ones with a matching rule, you could print something like:
> > > >
> > > >
> > > Is the act of printing/syslogging a rule in an of itself?
> >
> > No, as currently the only way stuff ends up in the syslog is if
> > DEBUG=true is used on the build line.
> >
> > But it's sounding like we might want to change that... :)
>
> How about this in the syslog after connect/disconnect?
>
>   Jan 15 05:07:45 pim udev[28007]: configured rule in '/etc/udev/udev.rules' at line 17 applied, 'video*' becomes 'video/webcam%n'
>   Jan 15 05:07:45 pim udev[28007]: creating device node '/udev/video/webcam0'
>   Jan 15 05:07:47 pim udev[28015]: removing device node '/udev/video/webcam0'

Here is a slightly better version. I've created a logging.h file and
moved the debug macros from udev.h in there.

If you type:

  'make'            - you will get a binary that prints one or two lines to syslog
                      if a device node is created or deleted

  'make LOG=false'  - you get a binary that prints asolutely nothing

  'make DEBUG=true' - the same as today, it will print all debug lines
2005-04-26 21:13:17 -07:00