Commit graph

11 commits

Author SHA1 Message Date
Jose Luis Duran
9881d68b1e nuageinit: Fix passwords
The hashed password usually contains a "$" sign, which, when used on a
shell, must be escaped.  Also, the plain text password may contain
special characters that require escaping.

Add a quick fix by enclosing it in single quotes.  Note that if the
plain text password contains a "'", it will still fail.  This will be
properly fixed in later commits.

Some here documents require the document to be a string literal,
especially when passing invalid characters.  Enclose it in single
quotes.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit b9ce743c5447e90c2c97f4d49e048c301f708527)
2024-10-08 09:04:01 +02:00
Jose Luis Duran
182ff41e84 nuageinit: Standardize warning/error messages
Standardize the utilities from nuage.lua, to return nil on failure, plus
an error message as a second result, and some value different from nil
on success.

Make warnmsg() and errmsg() append "nuageinit: " by default.  Pass an
optional second parameter as false to avoid printing this tag.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit 945632ca76117029e7bd1f46d17ccb378973daf7)
2024-10-08 09:04:01 +02:00
Jose Luis Duran
1eaf3331ea nuageinit: Replace os.execute with Lua libraries
Prefer posix.sys.stat's chmod() to os.execute().  While here, change the
name of the locals to be more descriptive.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit 9b2d92addc31ba6f5696c85d184a45d43e9073dc)
2024-10-08 09:04:01 +02:00
Jose Luis Duran
68c7c28d0e nuageinit: Lua check and lint files
Mostly white space, style, and luacheck compliance.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit 504981357aa36365784458cfe8d9e23097bfac7b)
2024-10-08 09:04:01 +02:00
Baptiste Daroussin
701ac3adcb nuageinit: improve debugging when mkdir fails
(cherry picked from commit a6ecbf2b35856e312d1e826b206142b9f930a760)
2024-09-03 09:05:25 +02:00
Jose Luis Duran
3dbc333a9e nuageinit: Fix the homedir variable name
cloud-init uses homedir, not home.

(cherry picked from commit 7aecd689e362330a035a199afbe5707a8c4edc9c)
2024-09-03 09:05:24 +02:00
Jose Luis Duran
6171791787 nuageinit: Set recommended SSH permissions
As stated in sshd(8), the recommended permissions for ~/.ssh are
read/write/execute for the user, and not accessible by others; and the
recommended permissions for ~/.ssh/authorized_keys are read/write for
the user, and not accessible by others.

(cherry picked from commit 07d17ca189fcf3cc44b7706040b05ca8135c3b85)
2024-09-03 09:05:24 +02:00
Jose Luis Duran
c7887c8e2e nuageinit: Accept plain text passwords
Per pw(8), when -H is set, the password should be supplied already
encrypted in a form suitable for writing directly to the password
database (passwd in cloud-init tems); -h provides a special interface by
which interactive scripts can set an account password using pw(8) in
plain text (plain_text_passwd in cloud-init terms).

The default user (freebsd) is defined with a plain_text_passwd
(freebsd), not with an encrypted one.

(cherry picked from commit 7b73ecfe648487c7706ac2b854dcf1435e60e4ca)
2024-09-03 09:05:24 +02:00
Baptiste Daroussin
3cfc085f8a nuageinit: make addsshkey friendly for testsuite
(cherry picked from commit fa07b02f6e09f776b3afe5709e8fee1764c11a2a)
2024-06-27 10:55:07 +02:00
Baptiste Daroussin
12e584c11e nuageinit: use pw(8) instead of getent(1)
pw(8) allows to seek for users in a custom rootdir, which makes it
easier for a testsuite

MFC After:	3 days

(cherry picked from commit 83fcab792c9d7f13f7e8bd73cf1850ba74f49341)
2024-06-27 10:55:06 +02:00
Baptiste Daroussin
16a6da44e2 nuageinit: add basic support for cloudinit.
this is a very early script to support cloudinit, it does not intend to
be a full featured cloudinit client, but will support a good enough
subset to be viable in most case.

It support nocloud and openstack config-2 config drive mode (iso9660 or
msdosfs)

The following features are currently supported:
- adding users (including a default user named 'freebsd' with password
  'freebsd'
- adding groups
- adding ssh keys
- static ipv4, static ipv6, dynamic ipv4

With this one is able to use the 'bring your own image feature" out of
box.

It is expected that the script grows the support of other clouds
supporting cloud-init, contributions are welcomed.

It is designed to be only run once via the firstboot mecanism.

Sponsored by:	OVHCloud
Differential Revision:	https://reviews.freebsd.org/D44141

(cherry picked from commit a42d6f76018e4ed8324e319ab48aac904bda437c)
(cherry picked from commit c051f22bce42d920abba61bd7cf4ef5b6a270ffa)
(cherry picked from commit b8c053c9a612651d4909f7a323088f3e92485b7b)
(cherry picked from commit 9eae9233fdcc946945f4191e1413f548adfa2943)
2024-04-11 13:52:52 +02:00