penguins-eggs 25.11.29 → 25.12.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/.oclif.manifest.json +1 -1
  2. package/README.md +118 -127
  3. package/README.pdf +10950 -11893
  4. package/addons/eggs/theme/livecd/simple.grub.main.cfg +3 -3
  5. package/conf/derivatives.yaml +2 -1
  6. package/conf/distros/buster/calamares/calamares-modules/cleanup/cleanup.sh +1 -1
  7. package/conf/distros/focal/calamares/calamares-modules/cleanup/cleanup.sh +1 -1
  8. package/conf/distros/noble/calamares/calamares-modules/cleanup/cleanup.sh +1 -1
  9. package/conf/distros/noble/calamares/libexec/calamares-l10n-helper.sh +2 -1
  10. package/conf/distros/noble/calamares/settings.yml +1 -0
  11. package/conf/distros/trixie/calamares/calamares-modules/cleanup/cleanup.sh +1 -1
  12. package/conf/exclude.list.d/var.list +11 -6
  13. package/dist/appimage/dependency-manager.js +1 -1
  14. package/dist/classes/cli-autologin.d.ts +37 -4
  15. package/dist/classes/cli-autologin.js +153 -115
  16. package/dist/classes/compressors.d.ts +7 -10
  17. package/dist/classes/compressors.js +44 -31
  18. package/dist/classes/daddy.js +4 -1
  19. package/dist/classes/distro.js +2 -2
  20. package/dist/classes/diversions.js +2 -3
  21. package/dist/classes/incubation/fisherman-helper/initcpio.d.ts +3 -5
  22. package/dist/classes/incubation/fisherman-helper/initcpio.js +28 -20
  23. package/dist/classes/incubation/fisherman-helper/settings.js +1 -1
  24. package/dist/classes/incubation/fisherman.js +1 -1
  25. package/dist/classes/incubation/incubator.d/manjaro.js +1 -0
  26. package/dist/classes/incubation/incubator.js +1 -1
  27. package/dist/classes/ovary.d/create-xdg-autostart.js +1 -1
  28. package/dist/classes/ovary.d/edit-live-fs.d.ts +2 -13
  29. package/dist/classes/ovary.d/edit-live-fs.js +33 -146
  30. package/dist/classes/ovary.d/fertilization.js +1 -1
  31. package/dist/classes/ovary.d/luks-home.js +33 -19
  32. package/dist/classes/ovary.d/luks-root.d.ts +1 -2
  33. package/dist/classes/ovary.d/luks-root.js +46 -27
  34. package/dist/classes/ovary.d/luks-shrink.d.ts +14 -0
  35. package/dist/classes/ovary.d/luks-shrink.js +86 -0
  36. package/dist/classes/ovary.d/make-dot-disk.js +1 -1
  37. package/dist/classes/ovary.d/produce.js +64 -22
  38. package/dist/classes/ovary.d/user-create-live.d.ts +4 -10
  39. package/dist/classes/ovary.d/user-create-live.js +82 -84
  40. package/dist/classes/ovary.d/users-remove.d.ts +5 -6
  41. package/dist/classes/ovary.d/users-remove.js +61 -31
  42. package/dist/classes/ovary.d.ts +5 -3
  43. package/dist/classes/ovary.js +5 -3
  44. package/dist/classes/pacman.d/alpine.js +2 -2
  45. package/dist/classes/pacman.d/archlinux.js +2 -2
  46. package/dist/classes/pacman.d/debian.js +2 -3
  47. package/dist/classes/pacman.d/fedora.js +2 -3
  48. package/dist/classes/pacman.d/openmamba.js +2 -3
  49. package/dist/classes/pacman.d/opensuse.js +2 -3
  50. package/dist/classes/pacman.d.ts +0 -5
  51. package/dist/classes/pacman.js +3 -16
  52. package/dist/classes/pve-live.js +1 -1
  53. package/dist/classes/settings.js +1 -1
  54. package/dist/classes/sys-users.d.ts +76 -0
  55. package/dist/classes/sys-users.js +206 -0
  56. package/dist/classes/utils.d/kernel.js +3 -3
  57. package/dist/classes/utils.d.ts +15 -6
  58. package/dist/classes/utils.js +80 -47
  59. package/dist/classes/xdg.js +1 -1
  60. package/dist/classes/yolk.js +3 -5
  61. package/dist/commands/export/appimage.js +3 -3
  62. package/dist/commands/export/pkg.js +3 -3
  63. package/dist/commands/export/tarballs.js +3 -3
  64. package/dist/commands/krill.js +1 -1
  65. package/dist/commands/produce.js +14 -5
  66. package/dist/commands/setup/install.js +1 -1
  67. package/dist/commands/setup/purge.js +1 -1
  68. package/dist/commands/tools/yolk.js +1 -1
  69. package/dist/commands/update.js +1 -2
  70. package/dist/interfaces/calamares/i-calamares-branding.d.ts +56 -38
  71. package/dist/interfaces/calamares/i-calamares-branding.js +10 -0
  72. package/dist/interfaces/i-exec.d.ts +1 -0
  73. package/dist/krill/classes/prepare.d/location.js +1 -1
  74. package/dist/krill/classes/prepare.d/partitions.js +1 -1
  75. package/dist/krill/classes/prepare.d/users.js +2 -2
  76. package/dist/krill/classes/prepare.js +5 -5
  77. package/dist/krill/classes/sequence.d/add_user.d.ts +3 -15
  78. package/dist/krill/classes/sequence.d/add_user.js +87 -57
  79. package/dist/krill/classes/sequence.d/change_password.d.ts +5 -7
  80. package/dist/krill/classes/sequence.d/change_password.js +25 -10
  81. package/dist/krill/classes/sequence.d/del_live_user.d.ts +5 -7
  82. package/dist/krill/classes/sequence.d/del_live_user.js +39 -25
  83. package/dist/krill/classes/sequence.d/fstab.js +2 -2
  84. package/dist/krill/classes/sequence.d/grubcfg.d.ts +3 -7
  85. package/dist/krill/classes/sequence.d/grubcfg.js +33 -13
  86. package/dist/krill/classes/sequence.d/mkfs.js +2 -3
  87. package/dist/krill/classes/sequence.d/unpackfs.d.ts +2 -4
  88. package/dist/krill/classes/sequence.d/unpackfs.js +8 -5
  89. package/dist/krill/classes/sequence.d.ts +1 -5
  90. package/dist/krill/classes/sequence.js +28 -32
  91. package/dist/krill/components/finished.js +2 -2
  92. package/dist/krill/components/install.js +2 -2
  93. package/dist/krill/components/keyboard.js +2 -2
  94. package/dist/krill/components/location.js +2 -2
  95. package/dist/krill/components/network.js +2 -2
  96. package/dist/krill/components/partitions.js +2 -2
  97. package/dist/krill/components/summary.js +2 -2
  98. package/dist/krill/components/title.js +2 -2
  99. package/dist/krill/components/users.js +2 -2
  100. package/dist/krill/components/welcome.js +2 -2
  101. package/dist/krill/lib/select_installation_device.js +1 -1
  102. package/dist/krill/lib/select_replaced_partition.js +1 -1
  103. package/dist/lib/utils.d.ts +52 -19
  104. package/dist/lib/utils.js +271 -20
  105. package/manpages/doc/man/eggs.1.gz +0 -0
  106. package/manpages/doc/man/eggs.html +8 -8
  107. package/package.json +9 -9
  108. package/perrisbrewery/template/dependencies.yaml +1 -0
  109. package/scripts/boot-encrypted-root.sh +220 -0
  110. package/scripts/mount-encrypted-home.sh +324 -0
  111. package/scripts/restore_homecrypt_krill.sh +93 -0
  112. package/dracut/create-symlink +0 -71
  113. package/dracut/dracut-log.txt +0 -3
  114. package/dracut/export +0 -4
  115. package/dracut/export-dracut-analysis +0 -51
  116. package/dracut/export-dracut-log +0 -2
  117. package/dracut/mkisofs +0 -10
  118. package/dracut/renew-initramfs +0 -17
  119. package/dracut/sbin2bin +0 -10
  120. package/dracut/update-dracut-conf-d +0 -2
  121. package/dracut/update-dracut-modules +0 -62
@@ -144,7 +144,7 @@ export default class Produce extends Command {
144
144
  const yolkRenew = flags.yolk;
145
145
  const { nointeractive } = flags;
146
146
  const { noicon } = flags;
147
- // if clone or homecrypt includeRootHome = true
147
+ // if clone, homecrypt, fullcrypt
148
148
  const includeRootHome = flags.includeRootHome || clone || homecrypt;
149
149
  let { kernel } = flags;
150
150
  if (kernel === undefined) {
@@ -209,14 +209,23 @@ export default class Produce extends Command {
209
209
  let message = "this is a GUI system, calamares is available, but NOT installed\n";
210
210
  Utils.warning(message);
211
211
  }
212
- if (fullcrypt) {
212
+ /**
213
+ * se è appImage e fullcrypt esce
214
+ */
215
+ if (Utils.isAppImage() && fullcrypt) {
216
+ Utils.warning("eggs produce --fullcrypt cannot be used on AppImage");
217
+ console.log(`\nyou can try: "sudo eggs produce --homecrypt"`);
218
+ process.exit(9);
219
+ }
220
+ if (!Utils.isAppImage() && fullcrypt) {
213
221
  const distro = new Distro();
214
- if (distro.familyId === 'debian') {
215
- Utils.info("Use penguins-eggs and this option in particular with extreme caution, and ALWAYS first try it out in a test environment.");
222
+ if (distro.familyId === 'debian' && (distro.codenameId === 'trixie' || distro.codenameId === 'excalibur')) {
223
+ Utils.info("Use eggs --fullcrypt with extreme caution, and ALWAYS first try it out in a test environment.");
216
224
  Utils.sleep(3000);
217
225
  }
218
226
  else {
219
- Utils.warning("This option is still in the experimental phase and can only be tested on Debian trixie");
227
+ Utils.warning(`eggs produce --fullcrypt cannot be used on ${distro.distroId}/${distro.codenameId}`);
228
+ console.log(`\nyou can try: "sudo eggs produce --homecrypt"`);
220
229
  process.exit(9);
221
230
  }
222
231
  }
@@ -10,7 +10,7 @@ import Utils from '../../classes/utils.js';
10
10
  import Pacman from '../../classes/pacman.js';
11
11
  import { Command } from '@oclif/core';
12
12
  import { DependencyManager } from '../../appimage/dependency-manager.js';
13
- import { execSync } from 'node:child_process';
13
+ import { execSync } from '../../lib/utils.js';
14
14
  export default class Install extends Command {
15
15
  static description = 'Automatically check and install system prerequisites';
16
16
  static examples = [
@@ -10,7 +10,7 @@ import Utils from '../../classes/utils.js';
10
10
  import Pacman from '../../classes/pacman.js';
11
11
  import { Command } from '@oclif/core';
12
12
  import { DependencyManager } from '../../appimage/dependency-manager.js';
13
- import { execSync } from 'node:child_process';
13
+ import { execSync } from '../../lib/utils.js';
14
14
  export default class Purge extends Command {
15
15
  static description = 'Automatically check and install system prerequisites';
16
16
  static examples = [
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { Command, Flags } from '@oclif/core';
9
9
  import fs from 'node:fs';
10
- import shx from 'shelljs';
10
+ import { shx } from '../../lib/utils.js';
11
11
  import Utils from '../../classes/utils.js';
12
12
  import Yolk from '../../classes/yolk.js';
13
13
  /**
@@ -11,8 +11,7 @@ import Distro from '../classes/distro.js';
11
11
  import Tools from '../classes/tools.js';
12
12
  import Utils from '../classes/utils.js';
13
13
  import Diversions from '../classes/diversions.js';
14
- import { exec } from '../lib/utils.js';
15
- import { spawn } from 'child_process';
14
+ import { exec, spawn } from '../lib/utils.js';
16
15
  import axios from 'axios';
17
16
  import https from 'node:https';
18
17
  const agent = new https.Agent({
@@ -1,46 +1,64 @@
1
1
  /**
2
2
  * ./src/interfaces/i-calamares-branding.ts
3
- * penguins-eggs v.25.7.x / ecmascript 2020
3
+ * penguins-eggs v.25.x / ecmascript 2020
4
4
  * author: Piero Proietti
5
5
  * email: piero.proietti@gmail.com
6
6
  * license: MIT
7
+ *
8
+ * Questa interfaccia è allineata con la struttura reale di branding.desc
9
+ * (basata sull'output 'cat /etc/calamares/branding/eggs/branding.desc').
10
+ */
11
+ /**
12
+ * 💡 Interfaccia per la sezione 'strings'
13
+ * Contiene le informazioni testuali del prodotto.
14
+ */
15
+ export interface IBrandingStrings {
16
+ bootloaderEntryName: string;
17
+ knownIssuesUrl: string;
18
+ productName: string;
19
+ productUrl: string;
20
+ releaseNotesUrl: string;
21
+ shortProductName: string;
22
+ shortVersion: string;
23
+ shortVersionedName: string;
24
+ supportUrl: string;
25
+ version: string;
26
+ versionedName: string;
27
+ }
28
+ /**
29
+ * 💡 Interfaccia per la sezione 'images'
30
+ * Contiene i nomi dei file delle risorse grafiche.
31
+ */
32
+ export interface IBrandingImages {
33
+ productIcon: string;
34
+ productLogo: string;
35
+ productWelcome: string;
36
+ }
37
+ /**
38
+ * 💡 Interfaccia per la sezione 'style'
39
+ * Contiene le definizioni dei colori per l'interfaccia.
40
+ * Nota: Sono incluse sia le varianti con maiuscola che minuscola trovate nel tuo file.
41
+ */
42
+ export interface IBrandingStyle {
43
+ SidebarBackground: string;
44
+ SidebarBackgroundCurrent: string;
45
+ SidebarText: string;
46
+ SidebarTextCurrent: string;
47
+ sidebarBackground: string;
48
+ sidebarBackgroundCurrent: string;
49
+ sidebarText: string;
50
+ sidebarTextCurrent: string;
51
+ }
52
+ /**
53
+ * 💡 Interfaccia Principale: IBranding
54
+ * Mappa la struttura radice del file YAML branding.desc.
7
55
  */
8
56
  export interface IBranding {
9
- /** Il nome completo della distribuzione (es. "My Awesome OS"). */
10
- string_product_name: string;
11
- /** La versione della distribuzione (es. "2025.10"). */
12
- string_product_version: string;
13
- /** Un URL per il sito web del progetto. */
14
- string_product_url?: string;
15
- /** Un titolo per le note di rilascio. */
16
- string_release_title?: string;
17
- /** Il colore principale usato per gli accenti (pulsanti, selezioni). */
18
- color_accent?: string;
19
- /** Colore del testo principale. */
20
- color_text?: string;
21
- /** Colore di sfondo principale della finestra. */
22
- color_background?: string;
23
- /** Colore di sfondo della barra laterale. */
24
- color_sidebar_background?: string;
25
- /** Colore del testo nella barra laterale. */
26
- color_sidebar_text?: string;
27
- /** Logo principale mostrato nell'installer. */
28
- logo?: string;
29
- /** Icona del prodotto. */
30
- product_icon?: string;
31
- /** Icona della finestra dell'applicazione. */
32
- window_icon?: string;
33
- /** Larghezza iniziale della finestra in pixel. */
34
- window_width?: number;
35
- /** Altezza iniziale della finestra in pixel. */
36
- window_height?: number;
37
- /** Se `true`, posiziona la barra laterale a sinistra (default), altrimenti a destra. */
38
- sidebar_on_left?: boolean;
39
- /**
40
- * L'API da usare per lo slideshow. 'qml' per le slideshow tradizionali,
41
- * 'contextual' per quelle basate sul modulo in esecuzione.
42
- */
43
- slideshow_api?: 'qml' | 'contextual';
44
- /** Percorso al file QML principale dello slideshow (se slideshow_api è 'qml'). */
45
- slideshow_qml_path?: string;
57
+ componentName: string;
58
+ slideshow: string;
59
+ slideshowAPI: number;
60
+ welcomeStyleCalamares: boolean;
61
+ images: IBrandingImages;
62
+ strings: IBrandingStrings;
63
+ style: IBrandingStyle;
46
64
  }
@@ -1 +1,11 @@
1
+ /**
2
+ * ./src/interfaces/i-calamares-branding.ts
3
+ * penguins-eggs v.25.x / ecmascript 2020
4
+ * author: Piero Proietti
5
+ * email: piero.proietti@gmail.com
6
+ * license: MIT
7
+ *
8
+ * Questa interfaccia è allineata con la struttura reale di branding.desc
9
+ * (basata sull'output 'cat /etc/calamares/branding/eggs/branding.desc').
10
+ */
1
11
  export {};
@@ -8,4 +8,5 @@
8
8
  export interface IExec {
9
9
  code: number;
10
10
  data: string;
11
+ error?: string;
11
12
  }
@@ -12,7 +12,7 @@ import Location from '../../components/location.js';
12
12
  import selectRegions from '../../lib/select_regions.js';
13
13
  import selectZones from '../../lib/select_zones.js';
14
14
  import axios from 'axios';
15
- import shx from 'shelljs';
15
+ import { shx } from '../../../lib/utils.js';
16
16
  /**
17
17
  *
18
18
  * @param this
@@ -14,7 +14,7 @@ import selectFileSystemType from '../../lib/select_filesystem_type.js';
14
14
  import selectInstallationDevice from '../../lib/select_installation_device.js';
15
15
  import selectReplacedPartition from '../../lib/select_replaced_partition.js';
16
16
  import selectUserSwapChoice from '../../lib/select_user_swap_choice.js';
17
- import shx from 'shelljs';
17
+ import { shx } from '../../../lib/utils.js';
18
18
  import selectInstallationMode from '../../lib/select_installation_mode.js';
19
19
  /**
20
20
  * PARTITIONS
@@ -13,7 +13,7 @@ import getUsername from '../../lib/get_username.js';
13
13
  import getUserfullname from '../../lib/get_userfullname.js';
14
14
  import getPassword from '../../lib/get_password.js';
15
15
  import getHostname from '../../lib/get_hostname.js';
16
- import shx from 'shelljs';
16
+ import { shx } from '../../../lib/utils.js';
17
17
  /**
18
18
  * USERS
19
19
  */
@@ -36,7 +36,7 @@ export async function users() {
36
36
  }
37
37
  let hostname = this.krillConfig.hostname;
38
38
  if (hostname === '' || hostname === undefined) {
39
- hostname = shx.exec('cat /etc/hostname').trim();
39
+ hostname = shx.exec('cat /etc/hostname', { silent: true }).stdout.trim();
40
40
  }
41
41
  let autologin = true;
42
42
  let sameUserPassword = true;
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import os from 'os';
10
10
  import fs from 'fs';
11
- import shx from 'shelljs';
11
+ import { shx } from '../../lib/utils.js';
12
12
  import axios from 'axios';
13
13
  import { SwapChoice, InstallationMode, FsType } from './krill_enums.js';
14
14
  import Keyboards from '../../classes/keyboards.js';
@@ -199,15 +199,15 @@ export default class Krill {
199
199
  generateHostname(ip, random) {
200
200
  let hostname = this.krillConfig.hostname;
201
201
  if (hostname === '') {
202
- hostname = shx.exec('cat /etc/hostname', { silent: true }).trim();
202
+ hostname = shx.exec('cat /etc/hostname', { silent: true }).stdout.trim();
203
203
  }
204
204
  if (ip) {
205
205
  hostname = 'ip-' + Utils.address().replaceAll('.', '-');
206
206
  }
207
207
  if (random) {
208
- const fl = shx.exec(`tr -dc a-z </dev/urandom | head -c 2 ; echo ''`, { silent: true }).trim();
209
- const n = shx.exec(`tr -dc 0-9 </dev/urandom | head -c 3 ; echo ''`, { silent: true }).trim();
210
- const sl = shx.exec(`tr -dc a-z </dev/urandom | head -c 2 ; echo ''`, { silent: true }).trim();
208
+ const fl = shx.exec(`tr -dc a-z </dev/urandom | head -c 2 ; echo ''`, { silent: true }).stdout.trim();
209
+ const n = shx.exec(`tr -dc 0-9 </dev/urandom | head -c 3 ; echo ''`, { silent: true }).stdout.trim();
210
+ const sl = shx.exec(`tr -dc a-z </dev/urandom | head -c 2 ; echo ''`, { silent: true }).stdout.trim();
211
211
  hostname = `${os.hostname()}-${fl}${n}${sl}`;
212
212
  }
213
213
  return hostname;
@@ -1,20 +1,8 @@
1
1
  /**
2
- * ./src/krill/modules/add-user.ts
2
+ * ./src/krill/classes/secquence.d/add-user.ts
3
3
  * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
4
+ * * REFACTORED: Uses "The SysUser Master" class.
5
+ * Replaces chroot/binary dependencies with pure Node.js manipulation.
8
6
  */
9
7
  import Sequence from '../sequence.js';
10
- /**
11
- *
12
- * @param this
13
- * @param username
14
- * @param password
15
- * @param fullusername
16
- * @param roomNumber
17
- * @param workPhone
18
- * @param homePhone
19
- */
20
8
  export default function addUser(this: Sequence, username?: string, password?: string, fullusername?: string, roomNumber?: string, workPhone?: string, homePhone?: string): Promise<void>;
@@ -1,77 +1,107 @@
1
1
  /**
2
- * ./src/krill/modules/add-user.ts
2
+ * ./src/krill/classes/secquence.d/add-user.ts
3
3
  * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
4
+ * * REFACTORED: Uses "The SysUser Master" class.
5
+ * Replaces chroot/binary dependencies with pure Node.js manipulation.
8
6
  */
9
- import Utils from '../../../classes/utils.js';
7
+ import SysUsers from '../../../classes/sys-users.js';
8
+ import { exec } from '../../../lib/utils.js';
10
9
  import fs from 'fs';
10
+ import path from 'path';
11
11
  import yaml from 'js-yaml';
12
- import { exec } from '../../../lib/utils.js';
13
- /**
14
- *
15
- * @param this
16
- * @param username
17
- * @param password
18
- * @param fullusername
19
- * @param roomNumber
20
- * @param workPhone
21
- * @param homePhone
22
- */
23
12
  export default async function addUser(username = 'live', password = 'evolution', fullusername = '', roomNumber = '', workPhone = '', homePhone = '') {
24
- // adduser user
25
- let cmd = `chroot ${this.installTarget} adduser ${username} --home /home/${username} --shell /bin/bash --disabled-password --gecos "${fullusername},${roomNumber},${workPhone},${homePhone}" ${this.toNull}`;
26
- if (this.distro.familyId === 'archlinux') {
27
- cmd = `chroot ${this.installTarget} useradd --create-home --shell /bin/bash ${username} ${this.toNull}`;
28
- }
29
- else if (this.distro.familyId === 'fedora') {
30
- cmd = `chroot ${this.installTarget} adduser ${username} --create-home --shell /bin/bash --comment "${fullusername},${roomNumber},${workPhone},${homePhone}" ${this.toNull}`;
31
- }
32
- else if (this.distro.familyId === 'openmamba') {
33
- cmd = `chroot ${this.installTarget} useradd ${username} --create-home --shell /bin/bash --comment "${fullusername},${roomNumber},${workPhone},${homePhone}" ${this.toNull}`;
34
- }
35
- else if (this.distro.familyId === 'opensuse') {
36
- cmd = `chroot ${this.installTarget} useradd ${username} --create-home --shell /bin/bash --comment "${fullusername},${roomNumber},${workPhone},${homePhone}" ${this.toNull}`;
13
+ const target = this.installTarget;
14
+ const familyId = this.distro.familyId;
15
+ // --- 1. INIZIALIZZAZIONE SYSUSERS ---
16
+ const sysUsers = new SysUsers(target, familyId);
17
+ sysUsers.load(); // Carica passwd, shadow, group in memoria
18
+ console.log(`Creating user ${username} via SysUsers (Safe Mode)...`);
19
+ // --- 2. PREPARAZIONE DATI ---
20
+ // Shell detection (Fallback per Alpine/Minimal)
21
+ let shell = '/bin/bash';
22
+ if (!fs.existsSync(path.join(target, 'bin/bash')) && fs.existsSync(path.join(target, 'bin/ash'))) {
23
+ shell = '/bin/ash';
37
24
  }
38
- await exec(cmd, this.echo);
39
- cmd = `echo ${username}:${password} | chroot ${this.installTarget} /usr/sbin/chpasswd ${this.toNull}`;
40
- await exec(cmd, this.echo);
41
- let group = 'wheel';
42
- if (this.distro.familyId === 'debian') {
43
- group = 'sudo';
25
+ // Definizione oggetto utente
26
+ const newUser = {
27
+ username: username,
28
+ password: 'x',
29
+ uid: '1000', // Hardcoded per il primo utente (standard installer)
30
+ gid: '1000',
31
+ gecos: `${fullusername},${roomNumber},${workPhone},${homePhone}`,
32
+ home: `/home/${username}`,
33
+ shell: shell
34
+ };
35
+ // --- 3. MODIFICHE LOGICHE (IN MEMORIA) ---
36
+ // Aggiunge l'utente (gestisce passwd, shadow, group primario, subuid)
37
+ sysUsers.addUser(newUser, password);
38
+ // Aggiungi ai gruppi amministrativi (logica distro)
39
+ let adminGroup = 'wheel';
40
+ if (['debian', 'ubuntu', 'linuxmint', 'pop', 'neon'].includes(familyId)) {
41
+ adminGroup = 'sudo';
44
42
  }
45
- else if (this.distro.familyId === 'openmamba') {
46
- group = 'sysadmin';
43
+ else if (familyId === 'openmamba') {
44
+ adminGroup = 'sysadmin';
47
45
  }
48
- cmd = `chroot ${this.installTarget} usermod -aG ${group} ${username} ${this.toNull}`;
49
- await exec(cmd, this.echo);
50
- // add autologin group in archlinux
51
- await exec(cmd, this.echo);
52
- if (this.distro.familyId === 'archlinux') {
53
- await exec(`chroot ${this.installTarget} getent group autologin || groupadd autologin`);
54
- await exec(`chroot ${this.installTarget} usermod -aG autologin ${username}`);
55
- }
56
- /**
57
- * look to calamares/modules/users.conf for groups
58
- */
46
+ sysUsers.addUserToGroup(username, adminGroup);
47
+ // Aggiungi ai gruppi definiti in Calamares/Eggs config
59
48
  let usersConf = '/etc/calamares/modules/users.conf';
60
49
  if (!fs.existsSync(usersConf)) {
61
50
  usersConf = '/etc/penguins-eggs.d/krill/modules/users.conf';
62
51
  }
63
52
  if (fs.existsSync(usersConf)) {
64
- const o = yaml.load(fs.readFileSync(usersConf, 'utf8'));
65
- for (const group of o.defaultGroups) {
66
- const groupExists = await exec(`getent group ${group}`);
67
- if (groupExists.code == 0) {
68
- let addGroup = `chroot ${this.installTarget} usermod -aG ${group} ${username}`;
69
- await exec(addGroup);
53
+ try {
54
+ const content = fs.readFileSync(usersConf, 'utf8');
55
+ const o = yaml.load(content);
56
+ if (o && o.defaultGroups) {
57
+ for (const grp of o.defaultGroups) {
58
+ sysUsers.addUserToGroup(username, grp);
59
+ }
70
60
  }
71
61
  }
62
+ catch (e) {
63
+ console.error('Warning: Error parsing users.conf, skipping extra groups.', e);
64
+ }
65
+ }
66
+ // Fix specifico Archlinux (Autologin)
67
+ if (familyId === 'archlinux') {
68
+ sysUsers.addUserToGroup(username, 'autologin');
69
+ }
70
+ // --- 4. SALVATAGGIO ATOMICO SU DISCO ---
71
+ // Scrive tutti i file di config e applica chcon (SELinux) se necessario
72
+ await sysUsers.save();
73
+ // --- 5. CREAZIONE FISICA HOME DIRECTORY ---
74
+ // Queste operazioni toccano il filesystem reale, quindi usiamo exec/fs
75
+ const homeDir = path.join(target, newUser.home);
76
+ // Cleanup preventivo
77
+ await exec(`rm -rf ${homeDir}`, this.echo);
78
+ // Creazione da /etc/skel
79
+ const skelPath = path.join(target, 'etc', 'skel');
80
+ if (fs.existsSync(skelPath)) {
81
+ await exec(`mkdir -p ${homeDir}`, this.echo);
82
+ await exec(`cp -rT ${skelPath} ${homeDir}`, this.echo);
72
83
  }
73
84
  else {
74
- console.log(`cannot find: ${usersConf}!`);
75
- await Utils.pressKeyToExit();
85
+ await exec(`mkdir -p ${homeDir}`, this.echo);
86
+ }
87
+ // Permessi e Proprietario
88
+ await exec(`chown -R ${newUser.uid}:${newUser.gid} ${homeDir}`, this.echo);
89
+ // Privacy: 700 è meglio di 755 per la home utente
90
+ await exec(`chmod 700 ${homeDir}`, this.echo);
91
+ // --- 6. FIX SELINUX FINALE (HOME & RELABEL) ---
92
+ // SysUsers ha sistemato /etc/*, ma la home directory è appena stata creata
93
+ // e potrebbe avere contesti errati.
94
+ if (['fedora', 'rhel', 'centos', 'almalinux', 'rocky'].includes(familyId)) {
95
+ try {
96
+ console.log('Applying SELinux contexts to home directory...');
97
+ // Fix contesto home
98
+ await exec(`chcon -R -t user_home_t ${homeDir}`, { echo: false }).catch(() => { });
99
+ // Fix "Nuclear Option": forza relabel al boot se qualcosa fosse sfuggito
100
+ await exec(`touch ${target}/.autorelabel`, { echo: false });
101
+ }
102
+ catch (e) {
103
+ console.error('SELinux home fix warning:', e);
104
+ }
76
105
  }
106
+ console.log(`User ${username} successfully configured via SysUser Master.`);
77
107
  }
@@ -1,15 +1,13 @@
1
1
  /**
2
- * ./src/krill/modules/change-password.ts
2
+ * src/krill/modules/change-password.ts
3
3
  * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
4
+ * * REFACTORED: Uses "The SysUser Master" class.
5
+ * Changes user password directly in /etc/shadow safely (No binaries, SELinux safe).
8
6
  */
9
7
  import Sequence from '../sequence.js';
10
8
  /**
11
9
  * changePassword
12
- * @param name
13
- * @param newPassword
10
+ * @param name - Username to update
11
+ * @param newPassword - New plain text password
14
12
  */
15
13
  export default function changePassword(this: Sequence, name?: string, newPassword?: string): Promise<void>;
@@ -1,18 +1,33 @@
1
1
  /**
2
- * ./src/krill/modules/change-password.ts
2
+ * src/krill/modules/change-password.ts
3
3
  * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
4
+ * * REFACTORED: Uses "The SysUser Master" class.
5
+ * Changes user password directly in /etc/shadow safely (No binaries, SELinux safe).
8
6
  */
9
- import { exec } from '../../../lib/utils.js';
7
+ import SysUsers from '../../../classes/sys-users.js';
8
+ import fs from 'fs';
10
9
  /**
11
10
  * changePassword
12
- * @param name
13
- * @param newPassword
11
+ * @param name - Username to update
12
+ * @param newPassword - New plain text password
14
13
  */
15
14
  export default async function changePassword(name = 'live', newPassword = 'evolution') {
16
- const cmd = `echo ${name}:${newPassword} | chroot ${this.installTarget} /usr/sbin/chpasswd ${this.toNull}`;
17
- await exec(cmd, this.echo);
15
+ const target = this.installTarget;
16
+ const familyId = this.distro.familyId;
17
+ console.log(`Changing password for user '${name}' via SysUsers...`);
18
+ // 1. CARICAMENTO
19
+ // Se non esiste il target (caso strano), usciamo
20
+ if (!fs.existsSync(target)) {
21
+ console.error(`Error: Target ${target} not found for password change.`);
22
+ return;
23
+ }
24
+ const sysUsers = new SysUsers(target, familyId);
25
+ sysUsers.load();
26
+ // 2. MODIFICA (In Memoria)
27
+ // La classe SysUsers ha già il metodo setPassword che usa bcryptjs
28
+ // e aggiorna il timestamp di lastChange.
29
+ sysUsers.setPassword(name, newPassword);
30
+ // 3. SALVATAGGIO (Atomico + SELinux Fix)
31
+ await sysUsers.save();
32
+ console.log(`Password updated for '${name}'.`);
18
33
  }
@@ -1,14 +1,12 @@
1
1
  /**
2
- * ./src/krill/modules/del-live-user.ts
2
+ * src/krill/classes/sequence.d/del_live_user.ts
3
3
  * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
4
+ * * REFACTORED: Uses "The SysUser Master" class.
5
+ * Removes the live user from the installed target safely (SELinux friendly).
8
6
  */
9
7
  import Sequence from '../sequence.js';
10
8
  /**
11
- * delUser
12
- * va corretto con users.conf di calamares
9
+ * delLiveUser
10
+ * Rimuove l'utente live dal sistema installato (target)
13
11
  */
14
12
  export default function delLiveUser(this: Sequence): Promise<void>;
@@ -1,39 +1,53 @@
1
1
  /**
2
- * ./src/krill/modules/del-live-user.ts
2
+ * src/krill/classes/sequence.d/del_live_user.ts
3
3
  * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
4
+ * * REFACTORED: Uses "The SysUser Master" class.
5
+ * Removes the live user from the installed target safely (SELinux friendly).
8
6
  */
7
+ import SysUsers from '../../../classes/sys-users.js';
9
8
  import Utils from '../../../classes/utils.js';
10
9
  import { exec } from '../../../lib/utils.js';
10
+ import fs from 'fs';
11
+ import path from 'path';
11
12
  /**
12
- * delUser
13
- * va corretto con users.conf di calamares
13
+ * delLiveUser
14
+ * Rimuove l'utente live dal sistema installato (target)
14
15
  */
15
16
  export default async function delLiveUser() {
17
+ // Eseguiamo solo se siamo in modalità live (ovvero stiamo installando da una ISO)
16
18
  if (Utils.isLive()) {
17
- const user = this.settings.config.user_opt;
18
- let userExists = false;
19
- try {
20
- const cmd = `#!/bin/sh\ngetent passwd "${user}" > /dev/null`;
21
- await exec(cmd, Utils.setEcho(this.verbose));
22
- userExists = true;
19
+ // Recuperiamo il nome utente live (default: 'live' o quello impostato in build)
20
+ const liveUsername = this.settings.config.user_opt || 'live';
21
+ const target = this.installTarget;
22
+ const familyId = this.distro.familyId;
23
+ console.log(`Removing live user '${liveUsername}' from target via SysUsers...`);
24
+ // --- 1. CARICAMENTO CONFIGURAZIONE ---
25
+ // Istanziamo il nostro "Master" puntando alla root del sistema installato
26
+ const sysUsers = new SysUsers(target, familyId);
27
+ sysUsers.load();
28
+ // --- 2. RIMOZIONE LOGICA (IN MEMORIA) ---
29
+ // Rimuove l'utente da passwd, shadow, group e dai membri dei gruppi extra
30
+ sysUsers.removeUser(liveUsername);
31
+ // --- 3. SALVATAGGIO ATOMICO ---
32
+ // Scrive i file fisici e ripristina i contesti SELinux in un colpo solo
33
+ await sysUsers.save();
34
+ // --- 4. PULIZIA FILESYSTEM (File non gestiti da SysUsers) ---
35
+ // a) Home Directory
36
+ const homeDir = path.join(target, 'home', liveUsername);
37
+ if (fs.existsSync(homeDir)) {
38
+ await exec(`rm -rf ${homeDir}`, this.echo);
23
39
  }
24
- catch (error) {
25
- console.log(error);
40
+ // b) File Sudoers (spesso creato in /etc/sudoers.d/)
41
+ const sudoersFile = path.join(target, 'etc', 'sudoers.d', liveUsername);
42
+ if (fs.existsSync(sudoersFile)) {
43
+ fs.unlinkSync(sudoersFile);
44
+ console.log(`Removed sudoers file: ${sudoersFile}`);
26
45
  }
27
- finally {
28
- if (userExists) {
29
- let cmd = `chroot ${this.installTarget} deluser --remove-home ${user} ${this.toNull}`;
30
- if (this.distro.familyId === 'archlinux' ||
31
- this.distro.familyId === 'fedora' ||
32
- this.distro.familyId === 'opensuse') {
33
- cmd = `chroot ${this.installTarget} sudo userdel -r ${user} ${this.toNull}`;
34
- }
35
- await exec(cmd, this.echo);
36
- }
46
+ // c) Mail spool
47
+ const mailFile = path.join(target, 'var', 'mail', liveUsername);
48
+ if (fs.existsSync(mailFile)) {
49
+ fs.unlinkSync(mailFile);
37
50
  }
51
+ console.log(`Live user '${liveUsername}' removed successfully via SysUser Master.`);
38
52
  }
39
53
  }