[systemd-commits] 2 commits - fixme src/install.c src/util.c src/util.h units/fedora units/getty at .service.m4 units/graphical.target.m4 units/halt.target units/multi-user.target.m4 units/poweroff.target units/reboot.target units/rescue.target units/var-lock.mount units/var-run.mount
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Jun 18 12:56:28 PDT 2010
fixme | 8 +------
src/install.c | 17 ++++-----------
src/util.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
src/util.h | 2 +
units/fedora/prefdm.service | 3 ++
units/getty at .service.m4 | 8 +++++++
units/graphical.target.m4 | 6 +++++
units/halt.target | 3 ++
units/multi-user.target.m4 | 8 +++++++
units/poweroff.target | 3 ++
units/reboot.target | 3 ++
units/rescue.target | 3 ++
units/var-lock.mount | 3 ++
units/var-run.mount | 3 ++
14 files changed, 99 insertions(+), 18 deletions(-)
New commits:
commit 3d88bf660dae270c051c8319bba62c58a50c9d2b
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jun 18 21:56:21 2010 +0200
unit: add [Install] section to various service files
diff --git a/units/fedora/prefdm.service b/units/fedora/prefdm.service
index 3428026..2f4333f 100644
--- a/units/fedora/prefdm.service
+++ b/units/fedora/prefdm.service
@@ -14,3 +14,6 @@ Conflicts=shutdown.target
[Service]
ExecStart=/etc/X11/prefdm -nodaemon
+
+[Install]
+Alias=display-manager.service
diff --git a/units/getty at .service.m4 b/units/getty at .service.m4
index 8f3f628..5f6944f 100644
--- a/units/getty at .service.m4
+++ b/units/getty at .service.m4
@@ -23,3 +23,11 @@ ExecStart=GETTY %I
Restart=restart-always
RestartSec=0
KillMode=process-group
+
+[Install]
+Alias=getty.target.wants/getty at tty1.service
+Alias=getty.target.wants/getty at tty2.service
+Alias=getty.target.wants/getty at tty3.service
+Alias=getty.target.wants/getty at tty4.service
+Alias=getty.target.wants/getty at tty5.service
+Alias=getty.target.wants/getty at tty6.service
diff --git a/units/graphical.target.m4 b/units/graphical.target.m4
index 98555ad..6228026 100644
--- a/units/graphical.target.m4
+++ b/units/graphical.target.m4
@@ -20,3 +20,9 @@ Names=runlevel5.target
m4_ifdef(`TARGET_SUSE',
Names=runlevel5.target
)m4_dnl
+
+[Install]
+Alias=default.target
+m4_ifdef(`TARGET_FEDORA',
+Alias=runlevel5.target
+)m4_dnl
diff --git a/units/halt.target b/units/halt.target
index 9c735ea..77b4044 100644
--- a/units/halt.target
+++ b/units/halt.target
@@ -11,3 +11,6 @@
Description=Halt
Requires=halt.service
After=halt.service
+
+[Install]
+Alias=ctrl-alt-del.target
diff --git a/units/multi-user.target.m4 b/units/multi-user.target.m4
index 2cc7489..eb46b2b 100644
--- a/units/multi-user.target.m4
+++ b/units/multi-user.target.m4
@@ -20,3 +20,11 @@ Names=runlevel3.target
m4_ifdef(`TARGET_SUSE',
Names=runlevel3.target
)m4_dnl
+
+[Install]
+Alias=default.target
+m4_ifdef(`TARGET_FEDORA',
+Alias=runlevel2.target
+Alias=runlevel3.target
+Alias=runlevel4.target
+)m4_dnl
diff --git a/units/poweroff.target b/units/poweroff.target
index fe915c0..b2b56b2 100644
--- a/units/poweroff.target
+++ b/units/poweroff.target
@@ -12,3 +12,6 @@ Description=Power-Off
Names=runlevel0.target
Requires=poweroff.service
After=poweroff.service
+
+[Install]
+Alias=ctrl-alt-del.target
diff --git a/units/reboot.target b/units/reboot.target
index 3b03dbd..b3be52f 100644
--- a/units/reboot.target
+++ b/units/reboot.target
@@ -12,3 +12,6 @@ Description=Reboot
Names=runlevel6.target
Requires=reboot.service
After=reboot.service
+
+[Install]
+Alias=ctrl-alt-del.target
diff --git a/units/rescue.target b/units/rescue.target
index 8234f1a..0398f9b 100644
--- a/units/rescue.target
+++ b/units/rescue.target
@@ -12,3 +12,6 @@ Description=Rescue Prompt
Requires=basic.target
After=basic.target
Names=runlevel1.target
+
+[Install]
+Alias=kbrequest.target
diff --git a/units/var-lock.mount b/units/var-lock.mount
index dbfee59..a7668da 100644
--- a/units/var-lock.mount
+++ b/units/var-lock.mount
@@ -13,3 +13,6 @@ Before=local-fs.target
What=tmpfs
Where=/var/lock
Type=tmpfs
+
+[Install]
+WantedBy=local-fs.target
diff --git a/units/var-run.mount b/units/var-run.mount
index add284a..c082507 100644
--- a/units/var-run.mount
+++ b/units/var-run.mount
@@ -13,3 +13,6 @@ Before=local-fs.target
What=tmpfs
Where=/var/run
Type=tmpfs
+
+[Install]
+WantedBy=local-fs.target
commit c32dd69b46c6311148ed666095a13c5e6173c744
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jun 18 21:33:15 2010 +0200
install: make systemd-install useful for installation of template instances
diff --git a/fixme b/fixme
index dfd496d..7a0b499 100644
--- a/fixme
+++ b/fixme
@@ -28,8 +28,6 @@
* iCalendar semantics for the timer stuff (RFC2445)
-* provide sysv-like command line utilities
-
* ability to kill services? i.e. in contrast to stopping them, go directly
into killing mode?
@@ -63,14 +61,12 @@
* systemd-sysvinit as package
-* install must understand templates
-
* abstract namespace dbus socket
-* /sbin/shutdown argv[2..] message
-
* discuss NOTIFY_SOCKET, make it configurable? security implications?
+* when reading pid for watching, verify we are parent
+
Regularly:
* look for close() vs. close_nointr() vs. close_nointr_nofail()
diff --git a/src/install.c b/src/install.c
index 479a38c..e30f623 100644
--- a/src/install.c
+++ b/src/install.c
@@ -181,9 +181,6 @@ static bool unit_name_valid(const char *name) {
/* This is a minimal version of unit_name_valid() from
* unit-name.c */
- if (strchr(name, '/'))
- return false;
-
if (!*name)
return false;
@@ -386,6 +383,9 @@ static int install_info_symlink_alias(InstallInfo *i, const char *config_path) {
if ((r = create_symlink(i->path, alias_path)) != 0)
goto finish;
+
+ if (arg_action == ACTION_DISABLE)
+ rmdir_parents(alias_path, config_path);
}
r = 0;
@@ -422,15 +422,8 @@ static int install_info_symlink_wants(InstallInfo *i, const char *config_path) {
if ((r = create_symlink(i->path, alias_path)) != 0)
goto finish;
- if (arg_action == ACTION_DISABLE) {
- char *t;
-
- /* Try to remove .wants dir if we don't need it anymore */
- if (asprintf(&t, "%s/%s.wants", config_path, *s) >= 0) {
- rmdir(t);
- free(t);
- }
- }
+ if (arg_action == ACTION_DISABLE)
+ rmdir_parents(alias_path, config_path);
}
r = 0;
diff --git a/src/util.c b/src/util.c
index 2363ea2..78d8d5d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -893,6 +893,53 @@ int mkdir_p(const char *path, mode_t mode) {
return 0;
}
+int rmdir_parents(const char *path, const char *stop) {
+ size_t l;
+ int r = 0;
+
+ assert(path);
+ assert(stop);
+
+ l = strlen(path);
+
+ /* Skip trailing slashes */
+ while (l > 0 && path[l-1] == '/')
+ l--;
+
+ while (l > 0) {
+ char *t;
+
+ /* Skip last component */
+ while (l > 0 && path[l-1] != '/')
+ l--;
+
+ /* Skip trailing slashes */
+ while (l > 0 && path[l-1] == '/')
+ l--;
+
+ if (l <= 0)
+ break;
+
+ if (!(t = strndup(path, l)))
+ return -ENOMEM;
+
+ if (path_startswith(stop, t)) {
+ free(t);
+ return 0;
+ }
+
+ r = rmdir(t);
+ free(t);
+
+ if (r < 0)
+ if (errno != ENOENT)
+ return -errno;
+ }
+
+ return 0;
+}
+
+
char hexchar(int x) {
static const char table[16] = "0123456789abcdef";
diff --git a/src/util.h b/src/util.h
index 14c2859..9af2ca8 100644
--- a/src/util.h
+++ b/src/util.h
@@ -163,6 +163,8 @@ char *file_in_same_dir(const char *path, const char *filename);
int mkdir_parents(const char *path, mode_t mode);
int mkdir_p(const char *path, mode_t mode);
+int rmdir_parents(const char *path, const char *stop);
+
int get_process_name(pid_t pid, char **name);
char hexchar(int x);
More information about the systemd-commits
mailing list