-
Notifications
You must be signed in to change notification settings - Fork 64
FOGL-1499 Shutdown & restart using signals from systemctl script to avoid authentication issues #1590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FOGL-1499 Shutdown & restart using signals from systemctl script to avoid authentication issues #1590
Changes from all commits
157f100
3ca4194
1538b4e
501ca78
632f452
ec90756
19146df
e916267
ac7961f
249bf8c
eb11922
81c5532
6b6a257
b4165ef
774fd8e
5d32a71
889ba2a
bf39064
ab84b27
a48dc01
976bd84
5af6906
df7f375
bfabf9a
74c4920
b3e7523
a771efd
c24bb20
28e5797
47d5441
9391f4a
c67e9a6
5185733
40599df
d702a6a
6649135
1728f85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| fledge_version=3.1.0 | ||
| fledge_schema=76 | ||
| fledge_schema=77 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,13 +18,19 @@ For example, to start the Fledge system, open a session to the Fledge device and | |
|
|
||
| If authentication is enabled, which is the default mode for Fledge version 3.0 onward, then a number of the commands require authentication. Authentication can be accomplished by several means; | ||
|
|
||
| - Set the environment variable *USERNAME* to be the user name. | ||
| - Set the environment variable *FLEDGE_USER* to be the user name. | ||
ashish-jabble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - Pass the *-u* flag flag to the command to specify a user name. | ||
|
|
||
| - Create an authentication file | ||
ashish-jabble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - If neither of the above are done the user will be prompted to enter a user name. | ||
|
|
||
| In both cases the user will be prompted to enter a password. It is possible, but not recommended, to set an environment variable *PASSWORD* or pass the *-p* flag on the command line, with the plain text version of the password. | ||
| .. note:: | ||
|
|
||
| It is recommended to create an authentication file rather than pass parameters to the fledge command or set environment varaiables as both these methods can expose plain text user names, or passwords, to other users of the system. | ||
|
|
||
| In both cases the user will be prompted to enter a password. It is possible, but not recommended, to set an environment variable *FLEDGE_PASSWORD* or pass the *-p* flag on the command line, with the plain text version of the password. | ||
|
|
||
| .. code-block:: console | ||
|
|
||
|
|
@@ -47,6 +53,44 @@ It is also possible to use certificate based authentication to login to the syst | |
|
|
||
| .. note:: | ||
|
|
||
| Extreme caution should be taken when storing certificate files that they not be readable by any other user within the system. | ||
| Extreme caution should be taken when storing certificate files. They must not be readable by any other users within the system. | ||
|
|
||
| Following a successful authentication attempt a time based token is issued that allows the user to run further commands, for a limited time, without the need to authenticate again. | ||
|
|
||
| Authentication File | ||
| ------------------- | ||
|
|
||
| The prompting for username and password when using the *fledge* script can be bypassed if an authentication file is created. This is a file that should be created in a directory called *.fledge* in the user's home directory. | ||
|
|
||
| The file created should be called *auth* and contains the credentials required to login. This may either be a username and password or the filename of a certficate to use to authenticate. | ||
|
|
||
| .. note:: | ||
|
|
||
| The *auth* file will only be read if the permissions on that file are set such that only the owner can read the file. | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| $ chmod 600 ~/.fledge/auth | ||
|
|
||
| In older versions of Fledge the *auth* file was simply called *~/.fledge*. If the older *.fledge* file exists it will still be used. | ||
|
|
||
| An example *auth* file, using the default username and password would be as follows | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| FLEDGE_USER=admin | ||
| FLEDGE_PASSWORD=fledge | ||
|
|
||
| If using a certificate to authenticate the file would look as follow | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| FLEDGE_CERT=~/.auth/user.cert | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we allowing non systemctl role users as well? and expect them to copy their cert to this path?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, if they are using the fledge script then they are by definition Linux users so are able to do this. They don't have to of course, they can use any of the other methods to authenticate. |
||
|
|
||
| The file name, minus the extension, should match the user name of the user. | ||
|
|
||
| .. note:: | ||
|
|
||
| In the above example the certificate has been placed in the .auth directory, this is not a requirement and the user name choose to place the certificate in any location that is convienent for them. However the certificate file should be protected sich that it can not be red or copied by other users. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,7 @@ fi | |
| FLEDGE_ROOT="/usr/local/fledge" | ||
| FLEDGE_DATA="${FLEDGE_ROOT}/data" | ||
| FLEDGE_USER=`ls -ld "${FLEDGE_DATA}" | awk '{print $3}'` | ||
| FLEDGE_CERT="${FLEDGE_ROOT}/data/etc/certs/systemctl.cert" | ||
| PID_FILE="${FLEDGE_DATA}/var/run/fledge.core.pid" | ||
| PID=0 | ||
|
|
||
|
|
@@ -68,15 +69,27 @@ get_pid() { | |
|
|
||
| fledge_start() { | ||
| if [ "$IS_RHEL" = "" ]; then | ||
| sudo -u ${FLEDGE_USER} "${FLEDGE_ROOT}/bin/fledge" start > /dev/null | ||
| if [ -f "${FLEDGE_CERT}" ]; then | ||
| sudo -u ${FLEDGE_USER} "${FLEDGE_ROOT}/bin/fledge" -c "$FLEDGE_CERT}" start > /dev/null | ||
| else | ||
| sudo -u ${FLEDGE_USER} "${FLEDGE_ROOT}/bin/fledge" start > /dev/null | ||
| fi | ||
| elif [ -f "${FLEDGE_CERT}" ]; then | ||
| "${FLEDGE_ROOT}/bin/fledge" -c "${FLEDGE_CERT}" start > /dev/null | ||
| else | ||
| "${FLEDGE_ROOT}/bin/fledge" start > /dev/null | ||
| fi | ||
| } | ||
|
|
||
| fledge_stop() { | ||
| if [ "$IS_RHEL" = "" ]; then | ||
| sudo -u ${FLEDGE_USER} "${FLEDGE_ROOT}/bin/fledge" stop > /dev/null | ||
| if [ -f "${FLEDGE_CERT}" ]; then | ||
| sudo -u ${FLEDGE_USER} "${FLEDGE_ROOT}/bin/fledge" -c "${FLEDGE_CERT}" stop > /dev/null | ||
| else | ||
| sudo -u ${FLEDGE_USER} "${FLEDGE_ROOT}/bin/fledge" stop > /dev/null | ||
|
Comment on lines
+86
to
+89
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the Authentication Method is configured to use a password, authentication will not succeed when executing systemctl stop.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hence having a sysctemctl user who we can mandate must use certificates. |
||
| fi | ||
| elif [ -f "${FLEDGE_CERT}" ]; then | ||
| "${FLEDGE_ROOT}/bin/fledge" -c "${FLEDGE_CERT}" stop > /dev/null | ||
| else | ||
| "${FLEDGE_ROOT}/bin/fledge" stop > /dev/null | ||
| fi | ||
|
|
@@ -139,7 +152,7 @@ case "$1" in | |
| rm -f $PID_FILE | ||
| exit 1 | ||
| else | ||
| fledge_stop | ||
| kill -TERM $PID | ||
| echo "Fledge stopped [$PID]" | ||
| fi | ||
| fi | ||
|
|
@@ -148,7 +161,19 @@ case "$1" in | |
|
|
||
| restart) | ||
|
|
||
| $0 fledge_stop | ||
| get_pid | ||
| if [ $PID -eq 0 ]; then | ||
| echo "Fledge not running" | ||
| else | ||
| ps -p $PID | ||
| if [ $? -eq 1 ]; then | ||
| echo "Fledge not running (process dead but PID file exists)" | ||
| rm -f $PID_FILE | ||
| else | ||
| kill -TERM $PID | ||
| echo "Fledge stopped [$PID]" | ||
| fi | ||
| fi | ||
| $0 fledge_start | ||
| ;; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that being under $FLEDGE_DATA is a necessary condition; however, this does not address how we can prevent users from removing this certificate along the same path. In our documentation, we typically advise relocating the default certificates and changing the passwords of default users to prevent the potential leakage of certificates and passwords.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should relax that one. I can see for container based deployments it is an issue as everything not under FLEDGE_DATA will get destroyed on redeployment of the container. We probably need to think carefully about how we address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take the case of Centralised management deployment, which creates a new Root CA? The systemctl user certificate will not be working anymore.
Also, please note that, systemd does not work in containers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update FogLAMP Manage the handle this then. I suspect we are not going to find a single solution that will work in all cases.