[Midnightbsd-cvs] src [7091] trunk/lib/libmport: add register/ unregister functions for shells and wire in.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Wed Jul 15 07:07:04 EDT 2015
Revision: 7091
http://svnweb.midnightbsd.org/src/?rev=7091
Author: laffer1
Date: 2015-07-15 07:07:03 -0400 (Wed, 15 Jul 2015)
Log Message:
-----------
add register/unregister functions for shells and wire in. Now @shell will include a shell in /etc/shells automatically!
Modified Paths:
--------------
trunk/lib/libmport/bundle_read_install_pkg.c
trunk/lib/libmport/delete_primative.c
trunk/lib/libmport/mport_private.h
trunk/lib/libmport/util.c
Modified: trunk/lib/libmport/bundle_read_install_pkg.c
===================================================================
--- trunk/lib/libmport/bundle_read_install_pkg.c 2015-07-15 01:45:45 UTC (rev 7090)
+++ trunk/lib/libmport/bundle_read_install_pkg.c 2015-07-15 11:07:03 UTC (rev 7091)
@@ -231,6 +231,12 @@
goto ERROR;
}
+ /* shell registration */
+ if (type == ASSET_SHELL) {
+ if (mport_shell_register(file) != MPORT_OK)
+ goto ERROR;
+ }
+
/* for sample files, if we don't have an existing file
make a new one */
if (type == ASSET_SAMPLE) {
Modified: trunk/lib/libmport/delete_primative.c
===================================================================
--- trunk/lib/libmport/delete_primative.c 2015-07-15 01:45:45 UTC (rev 7090)
+++ trunk/lib/libmport/delete_primative.c 2015-07-15 11:07:03 UTC (rev 7091)
@@ -185,6 +185,11 @@
if (unlink(file) != 0)
mport_call_msg_cb(mport, "Could not unlink %s: %s", file, strerror(errno));
+ if (type == ASSET_SHELL) {
+ if (mport_shell_unregister(file) != MPORT_OK)
+ mport_call_msg_cb(mport, "Could not unregister shell: %s", file);
+ }
+
break;
case ASSET_UNEXEC:
if (mport_run_asset_exec(mport, data, cwd, file) != MPORT_OK) {
Modified: trunk/lib/libmport/mport_private.h
===================================================================
--- trunk/lib/libmport/mport_private.h 2015-07-15 01:45:45 UTC (rev 7090)
+++ trunk/lib/libmport/mport_private.h 2015-07-15 11:07:03 UTC (rev 7091)
@@ -1,6 +1,6 @@
/* $MidnightBSD$
*
- * Copyright (c) 2011, 2013 Lucas Holt
+ * Copyright (c) 2011, 2013, 2015 Lucas Holt
* Copyright (c) 2007-2009 Chris Reinhardt
* All rights reserved.
*
@@ -91,6 +91,8 @@
int mport_run_asset_exec(mportInstance *, const char *, const char *, const char *);
void mport_free_vec(void *);
int mport_decompress_bzip2(const char *, const char *);
+int mport_shell_register(const char *);
+int mport_shell_unregister(const char *);
/* Mport Bundle (a file containing packages) */
Modified: trunk/lib/libmport/util.c
===================================================================
--- trunk/lib/libmport/util.c 2015-07-15 01:45:45 UTC (rev 7090)
+++ trunk/lib/libmport/util.c 2015-07-15 11:07:03 UTC (rev 7091)
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2011, 2013 Lucas Holt
+ * Copyright (c) 2011, 2013, 2015 Lucas Holt
* Copyright (c) 2007-2009 Chris Reinhardt
* All rights reserved.
*
@@ -252,6 +252,26 @@
}
+int
+mport_shell_register(const char *shell_file)
+{
+ if (shell_file == NULL)
+ RETURN_ERROR(MPORT_ERR_FATAL, "Shell to register is invalid.");
+
+ return mport_xsystem(NULL, "echo %s >> /etc/shells", shell_file);
+}
+
+
+int
+mport_shell_unregister(const char *shell_file)
+{
+ if (shell_file == NULL)
+ RETURN_ERROR(MPORT_ERR_FATAL, "Shell to unregister is invalid.");
+
+ return mport_xsystem(NULL, "grep -v %s /etc/shells > /etc/shells.bak && mv /etc/shells.bak /etc/shells", shell_file);
+}
+
+
/*
* Quick test to see if a file exists.
*/
More information about the Midnightbsd-cvs
mailing list