summaryrefslogtreecommitdiff
path: root/udev_utils.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2005-02-09 04:37:32 +0100
committerGreg KH <gregkh@suse.de>2005-04-26 23:27:32 -0700
commitc1ab046124ebef3c82950b91ccfd1678d9f7fe5b (patch)
tree1b160f9cba6681028f8993ca723300611172b133 /udev_utils.c
parentbce52be81ec679bf080bb11f292c899d9fde084e (diff)
[PATCH] provide temporary device node for callouts to access the device
%N will create a temporary node for a callout a be sustituted with the name of the node.
Diffstat (limited to 'udev_utils.c')
-rw-r--r--udev_utils.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/udev_utils.c b/udev_utils.c
index 5b0355d0e9..ca46258def 100644
--- a/udev_utils.c
+++ b/udev_utils.c
@@ -112,6 +112,31 @@ int create_path(const char *path)
return mkdir(p, 0755);
}
+/* Reset permissions on the device node, before unlinking it to make sure,
+ * that permisions of possible hard links will be removed to.
+ */
+int unlink_secure(const char *filename)
+{
+ int retval;
+
+ retval = chown(filename, 0, 0);
+ if (retval)
+ dbg("chown(%s, 0, 0) failed with error '%s'", filename, strerror(errno));
+
+ retval = chmod(filename, 0000);
+ if (retval)
+ dbg("chmod(%s, 0000) failed with error '%s'", filename, strerror(errno));
+
+ retval = unlink(filename);
+ if (errno == ENOENT)
+ retval = 0;
+
+ if (retval)
+ dbg("unlink(%s) failed with error '%s'", filename, strerror(errno));
+
+ return retval;
+}
+
int parse_get_pair(char **orig_string, char **left, char **right)
{
char *temp;