|
Lines 13-18
Link Here
|
| 13 |
textdomain "security"; |
13 |
textdomain "security"; |
| 14 |
|
14 |
|
| 15 |
import "FileUtils"; |
15 |
import "FileUtils"; |
|
|
16 |
import "Package"; |
| 16 |
import "Pam"; |
17 |
import "Pam"; |
| 17 |
import "PamSettings"; |
18 |
import "PamSettings"; |
| 18 |
import "Progress"; |
19 |
import "Progress"; |
|
Lines 34-39
Link Here
|
| 34 |
]; |
35 |
]; |
| 35 |
// All other services should be turned off |
36 |
// All other services should be turned off |
| 36 |
|
37 |
|
|
|
38 |
// systemd target, defining ctrl-alt-del behavior |
| 39 |
string ctrl_alt_del_file = "/etc/systemd/system/ctrl-alt-del.target"; |
| 37 |
|
40 |
|
| 38 |
// return list of missing mandatory services in a runlevel |
41 |
// return list of missing mandatory services in a runlevel |
| 39 |
global list<list<string> > MissingMandatoryServices(integer runlevel) |
42 |
global list<list<string> > MissingMandatoryServices(integer runlevel) |
|
Lines 340-345
Link Here
|
| 340 |
} |
343 |
} |
| 341 |
|
344 |
|
| 342 |
/** |
345 |
/** |
|
|
346 |
* Read the information about ctrl+alt+del behavior |
| 347 |
* See bug 742783 for description |
| 348 |
*/ |
| 349 |
global string ReadConsoleShutdown () { |
| 350 |
|
| 351 |
string ret = "ignore"; |
| 352 |
|
| 353 |
if (Package::Installed ("systemd")) |
| 354 |
{ |
| 355 |
if (!FileUtils::Exists (ctrl_alt_del_file)) |
| 356 |
{ |
| 357 |
ret = "reboot"; |
| 358 |
} |
| 359 |
else |
| 360 |
{ |
| 361 |
string link = (string) SCR::Read (.target.symlink, ctrl_alt_del_file); |
| 362 |
if (link == "/lib/systemd/system/poweroff.target") |
| 363 |
{ |
| 364 |
ret = "halt"; |
| 365 |
} |
| 366 |
else if (link == "/lib/systemd/system/reboot.target" || |
| 367 |
link == "/lib/systemd/system/ctrl-alt-del.target") |
| 368 |
{ |
| 369 |
ret = "reboot"; |
| 370 |
} |
| 371 |
} |
| 372 |
return ret; |
| 373 |
} |
| 374 |
list inittab = SCR::Dir(.etc.inittab); |
| 375 |
if(contains(inittab, "ca")) { |
| 376 |
string ca = (string) SCR::Read(.etc.inittab.ca); |
| 377 |
if(issubstring(ca, "/bin/true") || issubstring(ca, "/bin/false")) |
| 378 |
Settings["CONSOLE_SHUTDOWN"] = "ignore"; |
| 379 |
else if(issubstring(ca, "reboot") || issubstring(ca, " -r")) |
| 380 |
Settings["CONSOLE_SHUTDOWN"] = "reboot"; |
| 381 |
else if(issubstring(ca, "halt") || issubstring(ca, " -h")) |
| 382 |
Settings["CONSOLE_SHUTDOWN"] = "halt"; |
| 383 |
else { |
| 384 |
y2error("Unknown ca status: %1", ca); |
| 385 |
Settings["CONSOLE_SHUTDOWN"] = "ignore"; |
| 386 |
} |
| 387 |
} |
| 388 |
else |
| 389 |
Settings["CONSOLE_SHUTDOWN"] = "ignore"; |
| 390 |
} |
| 391 |
|
| 392 |
/** |
| 343 |
* Read all security settings |
393 |
* Read all security settings |
| 344 |
* @return true on success |
394 |
* @return true on success |
| 345 |
*/ |
395 |
*/ |
|
Lines 371-392
Link Here
|
| 371 |
}); |
421 |
}); |
| 372 |
y2debug("Settings=%1", Settings); |
422 |
y2debug("Settings=%1", Settings); |
| 373 |
|
423 |
|
| 374 |
list inittab = SCR::Dir(.etc.inittab); |
424 |
Settings["CONSOLE_SHUTDOWN"] = ReadConsoleShutdown (); |
| 375 |
if(contains(inittab, "ca")) { |
|
|
| 376 |
string ca = (string) SCR::Read(.etc.inittab.ca); |
| 377 |
if(issubstring(ca, "/bin/true") || issubstring(ca, "/bin/false")) |
| 378 |
Settings["CONSOLE_SHUTDOWN"] = "ignore"; |
| 379 |
else if(issubstring(ca, "reboot") || issubstring(ca, " -r")) |
| 380 |
Settings["CONSOLE_SHUTDOWN"] = "reboot"; |
| 381 |
else if(issubstring(ca, "halt") || issubstring(ca, " -h")) |
| 382 |
Settings["CONSOLE_SHUTDOWN"] = "halt"; |
| 383 |
else { |
| 384 |
y2error("Unknown ca status: %1", ca); |
| 385 |
Settings["CONSOLE_SHUTDOWN"] = "ignore"; |
| 386 |
} |
| 387 |
} |
| 388 |
else |
| 389 |
Settings["CONSOLE_SHUTDOWN"] = "ignore"; |
| 390 |
|
425 |
|
| 391 |
y2debug("Settings=%1", Settings); |
426 |
y2debug("Settings=%1", Settings); |
| 392 |
|
427 |
|
|
Lines 493-498
Link Here
|
| 493 |
]; |
528 |
]; |
| 494 |
|
529 |
|
| 495 |
/** |
530 |
/** |
|
|
531 |
* Write the value of ctrl-alt-delete behavior |
| 532 |
*/ |
| 533 |
boolean WriteConsoleShutdown (string ca) { |
| 534 |
|
| 535 |
if (Package::Installed ("systemd")) |
| 536 |
{ |
| 537 |
if (ca == "reboot") |
| 538 |
{ |
| 539 |
SCR::Execute (.target.remove, ctrl_alt_del_file); |
| 540 |
} |
| 541 |
else if (ca == "halt") |
| 542 |
{ |
| 543 |
SCR::Execute (.target.bash, |
| 544 |
sformat ("ln -s -f /lib/systemd/system/poweroff.target %1", |
| 545 |
ctrl_alt_del_file)); |
| 546 |
} |
| 547 |
else |
| 548 |
{ |
| 549 |
SCR::Execute (.target.bash, |
| 550 |
sformat ("ln -s -f /dev/null %1", ctrl_alt_del_file)); |
| 551 |
} |
| 552 |
return true; |
| 553 |
} |
| 554 |
|
| 555 |
if(ca == "reboot") |
| 556 |
SCR::Write(.etc.inittab.ca, ":ctrlaltdel:/sbin/shutdown -r -t 4 now"); |
| 557 |
else if(ca == "halt") |
| 558 |
SCR::Write(.etc.inittab.ca, ":ctrlaltdel:/sbin/shutdown -h -t 4 now"); |
| 559 |
else |
| 560 |
SCR::Write(.etc.inittab.ca, ":ctrlaltdel:/bin/true"); |
| 561 |
SCR::Write(.etc.inittab, nil); |
| 562 |
|
| 563 |
// re-read the modified inittab (#83480) |
| 564 |
SCR::Execute (.target.bash, "/sbin/telinit q"); |
| 565 |
return true; |
| 566 |
} |
| 567 |
|
| 568 |
|
| 569 |
/** |
| 496 |
* Write all security settings |
570 |
* Write all security settings |
| 497 |
* @return true on success |
571 |
* @return true on success |
| 498 |
*/ |
572 |
*/ |
|
Lines 557-574
Link Here
|
| 557 |
if(Abort()) return false; |
631 |
if(Abort()) return false; |
| 558 |
Progress::NextStage(); |
632 |
Progress::NextStage(); |
| 559 |
|
633 |
|
| 560 |
string ca = Settings["CONSOLE_SHUTDOWN"]:"ignore"; |
634 |
WriteConsoleShutdown (Settings["CONSOLE_SHUTDOWN"]:"ignore"); |
| 561 |
if(ca == "reboot") |
|
|
| 562 |
SCR::Write(.etc.inittab.ca, ":ctrlaltdel:/sbin/shutdown -r -t 4 now"); |
| 563 |
else if(ca == "halt") |
| 564 |
SCR::Write(.etc.inittab.ca, ":ctrlaltdel:/sbin/shutdown -h -t 4 now"); |
| 565 |
else |
| 566 |
SCR::Write(.etc.inittab.ca, ":ctrlaltdel:/bin/true"); |
| 567 |
SCR::Write(.etc.inittab, nil); |
| 568 |
|
635 |
|
| 569 |
// re-read the modified inittab (#83480) |
|
|
| 570 |
SCR::Execute (.target.bash, "/sbin/telinit q"); |
| 571 |
|
| 572 |
/* Write pam settings */ |
636 |
/* Write pam settings */ |
| 573 |
if(Abort()) return false; |
637 |
if(Abort()) return false; |
| 574 |
Progress::NextStage(); |
638 |
Progress::NextStage(); |