MCDE dtsystemsettings: Security, three tabs (t0157)

New programs/dtsystemsettings/security.c with the reference's three tabs:

  General     "Require password to wake this computer from sleep or screen
              saver" writes dtsession's lock time (_DtSetSmState with
              SM_STATE_LOCKTIMEOUT; the Screen Saver page reads and writes the
              same field, so the two pages show one setting).  On: the lock at
              the saver's time, or ten minutes without a saver.  "Use secure
              virtual memory" is NetBSD's vm.swap_encrypt through McdeSys
              (now and in /etc/sysctl.conf, root).  Automatic login and a
              log-out after N minutes are shown as what the desktop has:
              dtlogin always asks for a name and a password, and dtsession
              has no idle logout -- the pane says so and greys the controls.
  Encryption  the cgd(4) volumes of /etc/cgd/cgd.conf, and the sentence that
              encrypting a disk is a decision of the installation, not of a
              running system; changing a passphrase is a follow-up.
  Firewall    the npf(7) state (rc.conf npf=YES, /etc/npf.conf); the rules
              are a follow-up -- a fixed template with the shares of the
              Sharing page, never free text.

McdeSys gained the security state: mcde_sys_swap_encrypt_get/_set,
mcde_sys_cgd_volumes, mcde_sys_firewall_get.  netbsd.c implements them
(sysctl(8) vm.swap_encrypt, /etc/sysctl.conf through a KeySet() that rc.conf
now uses too, /etc/cgd/cgd.conf, rc.conf's npf), linux.c answers
MCDE_SYS_ENOTSUP with a sentence saying whose feature it is.
test_sysinfo prints all three.

The pane's icon is new: programs/icons/McdeLock.pm (a padlock, palette
colours); "security" is a real pane now, not a greyed entry.

Measured under Xvfb with xdotool (dtsession started in the session):

  - the lock checkbox: _DT_SM_STATE_INFO on dtsession's window before the
    click 0xfff, ... lockTimeout 0x0; after it 0x100 (SM_STATE_LOCKTIMEOUT),
    lockTimeout 0x258 (600 s); a second click puts it back to 0x0;
  - the three tabs and their content (docs/screenshots/leopard/
    System-Preferences-Security-mcde.png with the lock on, ...-Encryption-
    mcde.png, ...-Firewall-mcde.png);
  - test_sysinfo on this (Linux) host prints the three MCDE_SYS_ENOTSUP
    sentences -- the pane shows them instead of dead controls;
  - make check programs/dtsystemsettings: test_panes PASS; the Sound and
    Keyboard & Mouse panes still switch their tabs after the layout fix
    below;
  - make programs/dtsystemsettings, lib/McdeSys exit=0.

A Motif lesson, saved in AGENTS.md: a row column inside the pane area takes
the other orientation unless told, a child added later to a tight-packed
column goes into the next column, and a page managed for the first time after
its widgets were built keeps a height of one line.  The pane therefore builds
its page fresh inside an XmPACK_COLUMN container on a tab change; the same
XmNorientation, XmVERTICAL went into the Sound and Keyboard & Mouse page
containers.

Not measured, because this host is not NetBSD or has no root: swapping
vm.swap_encrypt, reading cgd volumes, the npf state and writing npf rules.
They are the follow-up task for the VM.
This commit is contained in:
lotherk committed 2026-11-14 12:44:32 +00:00
1 parent c4f159477d
commit 020dd9ff5d
14 files changed
+629 -15

No files matched your search

+18
View File
@@ -145,6 +145,24 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
`~/.dt/screensaver`. The start time has the reference's seven steps
(3/5/15/30/60/120 minutes, never) and goes to dtsession as the saver
timeout.
- **Security**: `dtsystemsettings/security.c`, three tabs. "Require
password to wake ..." is dtsession's lock time (`_DtSetSmState` with
`SM_STATE_LOCKTIMEOUT`, the same field the Screen Saver page shows); with
the lock at the saver's time dtsession locks the screen when the saver
starts. Automatic login and a log-out after inactivity are shown as what
the desktop can do today (dtlogin always asks; dtsession has no idle
logout). Swap encryption, cgd volumes and the npf state come from
McdeSys (`mcde_sys_swap_encrypt_get/_set`, `mcde_sys_cgd_volumes`,
`mcde_sys_firewall_get`); the NetBSD backend is `netbsd.c`, on another
system the functions say so (`MCDE_SYS_ENOTSUP`) and the pane shows it.
Writing npf rules and changing a cgd passphrase are follow-ups.
- **Motif row columns in a pane**: a `xmRowColumnWidgetClass` created inside
the pane area (a vertical row column) takes the other orientation unless
`XmNorientation` is given; with `XmPACK_TIGHT` a child added *later* goes
into the next column, and a page managed for the first time after its
widgets were built keeps a height of one line. The Security pane therefore
builds its page fresh on a tab change inside a `XmPACK_COLUMN` container
(measured 2026-11-14, several dead ends).
- **Sound**: the pane is `dtsystemsettings/sound.c`, three tabs (Sound
Effects, Output, Input). The effects are the events of the session's
theme (`McdeSoundEventName`, a click sends `McdeSoundEvent`), the theme is
+27 -2
View File
@@ -18,8 +18,8 @@
* mcde_sys_info, mcde_sys_power, mcde_sys_interfaces, the sound, Bluetooth,
* battery, time zone, sharing, the network browser, disks, backup,
* user and software update functions (common.c, net.c, sound.c, users.c,
* netbsd.c, linux.c); the network setup and the host name setter are the
* contract still.
* netbsd.c, linux.c), and the security state (swap encryption, cgd, npf);
* the network setup and the host name setter are the contract still.
*/
#ifndef _Mcde_McdeSys_h
@@ -417,6 +417,31 @@ int mcde_sys_ntp_get(int *on, char *server, size_t len);
int mcde_sys_ntp_set(int on, const char *server);
int mcde_sys_time_set(time_t when);
/*
* Security
*
* Secure virtual memory is NetBSD's vm.swap_encrypt: the swap's pages are
* encrypted with a key in memory, so a powered-off disk does not show them.
* cgd(4) is NetBSD's encrypted disk; its volumes are listed in
* /etc/cgd/cgd.conf, and encrypting one is an install-time (sysinst)
* decision, not something a running system does. The packet filter is
* NetBSD's npf(7), configured in /etc/npf.conf and started by rc.conf's
* npf=YES; these functions read its state only.
*/
#define MCDE_SYS_CGD_ENTRY_LEN 192
/* 1 or 0 into ON: whether memory is encrypted in swap; MCDE_SYS_ENOTSUP on
* a system without vm.swap_encrypt */
int mcde_sys_swap_encrypt_get(int *on);
/* set it now and in /etc/sysctl.conf, for after the next start (root) */
int mcde_sys_swap_encrypt_set(int on);
/* the cgd(4) volumes as /etc/cgd/cgd.conf lists them ("wd0d /etc/cgd/wd0d"
* a line) into VOLS; the count, MCDE_SYS_ENOTSUP without cgd */
int mcde_sys_cgd_volumes(char (*vols)[MCDE_SYS_CGD_ENTRY_LEN], size_t max);
/* the packet filter's state: 1 on, 0 off into ON, its configuration file
* into CONF; MCDE_SYS_ENOTSUP on a system without npf */
int mcde_sys_firewall_get(int *on, char *conf, size_t len);
/*
* The time zone: names as the tz database has them ("Europe/Lisbon").
* /etc/localtime is a symbolic link into /usr/share/zoneinfo on NetBSD and
+39
View File
@@ -1278,3 +1278,42 @@ mcde_sys_net_browse(McdeSysNetHost *hosts, size_t max, int timeout_ms)
}
return n;
}
/* ---- security: NetBSD's alone ------------------------------------------- */
int
mcde_sys_swap_encrypt_get(int *on)
{
if (on != NULL)
*on = 0;
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "Secure virtual memory is "
"NetBSD's vm.swap_encrypt; this system is not NetBSD.");
}
int
mcde_sys_swap_encrypt_set(int on)
{
(void)on;
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "Secure virtual memory is "
"NetBSD's vm.swap_encrypt; this system is not NetBSD.");
}
int
mcde_sys_cgd_volumes(char (*vols)[MCDE_SYS_CGD_ENTRY_LEN], size_t max)
{
(void)vols;
(void)max;
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "cgd(4) is NetBSD's; this "
"system is not NetBSD.");
}
int
mcde_sys_firewall_get(int *on, char *conf, size_t len)
{
if (on != NULL)
*on = 0;
if (conf != NULL && len > 0)
conf[0] = '\0';
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "npf(7) is NetBSD's packet "
"filter; this system is not NetBSD.");
}
+106 -8
View File
@@ -479,22 +479,25 @@ mcde_sys_wifi_scan(const char *ifname, McdeSysWifi *nets, size_t max)
return n;
}
/* VAR=VALUE in rc.conf: the line of VAR replaced, or added at the end */
/* VAR=VALUE in FILE: the line of VAR replaced, or added at the end; the
* file's mode is kept and it is renamed over the old one, so a half-written
* configuration is never read (rc.conf and sysctl.conf both) */
static int
RcConfSet(const char *var, const char *value)
KeySet(const char *file, const char *var, const char *value)
{
char line[1024], tmp[] = "/etc/rc.conf.mcdeXXXXXX";
char line[1024], tmp[1024];
size_t vlen = strlen(var);
struct stat st;
FILE *from, *to;
int fd, done = 0;
if (stat(RC_CONF, &st) != 0 || (from = fopen(RC_CONF, "r")) == NULL)
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot read %s.", RC_CONF);
if (stat(file, &st) != 0 || (from = fopen(file, "r")) == NULL)
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot read %s.", file);
(void)snprintf(tmp, sizeof tmp, "%s.mcdeXXXXXX", file);
if ((fd = mkstemp(tmp)) < 0 || (to = fdopen(fd, "w")) == NULL) {
fclose(from);
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write beside %s.",
RC_CONF);
file);
}
while (fgets(line, sizeof line, from) != NULL) {
if (strncmp(line, var, vlen) == 0 && line[vlen] == '=') {
@@ -509,13 +512,20 @@ RcConfSet(const char *var, const char *value)
if (!done)
fprintf(to, "%s=%s\n", var, value);
if (fchmod(fd, st.st_mode & 07777) != 0 || fclose(to) != 0 ||
rename(tmp, RC_CONF) != 0) {
rename(tmp, file) != 0) {
unlink(tmp);
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", RC_CONF);
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", file);
}
return MCDE_SYS_OK;
}
/* VAR=VALUE in rc.conf */
static int
RcConfSet(const char *var, const char *value)
{
return KeySet(RC_CONF, var, value);
}
int
mcde_sys_wifi_join(const char *ifname, const char *ssid,
const char *passphrase)
@@ -1815,3 +1825,91 @@ mcde_sys_net_browse(McdeSysNetHost *hosts, size_t max, int timeout_ms)
browse = NULL;
return st.n;
}
/* ---- security: swap encryption, cgd, the packet filter ------------------ */
#define SYSCTL_CONF "/etc/sysctl.conf"
#define CGD_CONF "/etc/cgd/cgd.conf"
#define NPF_CONF "/etc/npf.conf"
int
mcde_sys_swap_encrypt_get(int *on)
{
char buf[32], *argv[4];
if (on == NULL)
return mcde_sys_fail(MCDE_SYS_EINVAL, "There is no place for the "
"value.");
argv[0] = (char *) "/sbin/sysctl";
argv[1] = (char *) "-n";
argv[2] = (char *) "vm.swap_encrypt";
argv[3] = NULL;
if (mcde_sys_capture(argv, buf, sizeof buf) != MCDE_SYS_OK)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "The system does not say "
"whether memory is encrypted in swap.");
*on = atoi(buf) != 0;
return MCDE_SYS_OK;
}
int
mcde_sys_swap_encrypt_set(int on)
{
char val[32], *argv[4];
if (geteuid() != 0)
return mcde_sys_fail(MCDE_SYS_EPERM, "Secure virtual memory "
"needs the administrator.");
(void)snprintf(val, sizeof val, "vm.swap_encrypt=%d", on ? 1 : 0);
argv[0] = (char *) "/sbin/sysctl";
argv[1] = (char *) "-w";
argv[2] = val;
argv[3] = NULL;
if (mcde_sys_run(argv) != MCDE_SYS_OK)
return mcde_sys_fail(MCDE_SYS_EFAIL, "sysctl(8) did not take "
"vm.swap_encrypt.");
/* and after the next start: /etc/sysctl.conf */
return KeySet(SYSCTL_CONF, "vm.swap_encrypt", on ? "1" : "0");
}
int
mcde_sys_cgd_volumes(char (*vols)[MCDE_SYS_CGD_ENTRY_LEN], size_t max)
{
char line[256];
FILE *fp = fopen(CGD_CONF, "r");
int n = 0;
if (fp == NULL)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "This system has no "
"cgd(4) configuration (%s).", CGD_CONF);
while (vols != NULL && n < (int)max &&
fgets(line, sizeof line, fp) != NULL) {
char *p = line;
line[strcspn(line, "\r\n")] = '\0';
while (*p == ' ' || *p == '\t')
p++;
if (*p == '\0' || *p == '#')
continue;
(void)snprintf(vols[n], MCDE_SYS_CGD_ENTRY_LEN, "%s", p);
n++;
}
fclose(fp);
return n;
}
int
mcde_sys_firewall_get(int *on, char *conf, size_t len)
{
char v[32];
if (on == NULL || conf == NULL)
return mcde_sys_fail(MCDE_SYS_EINVAL, "There is no place for "
"the state.");
if (access("/sbin/npfctl", X_OK) != 0)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "This system has no "
"npf(7) (/sbin/npfctl).");
(void)snprintf(conf, len, "%s", NPF_CONF);
/* rc.conf's npf=YES starts it at boot (rc.d/npf reads it) */
*on = RcConfGet("npf", v, sizeof v) && strcasecmp(v, "YES") == 0;
return MCDE_SYS_OK;
}
+21
View File
@@ -207,6 +207,27 @@ main(void)
else
printf("update (%s)\n", mcde_sys_error());
}
{
char vols[8][MCDE_SYS_CGD_ENTRY_LEN], conf[128];
int on = -1, n, k;
if (mcde_sys_swap_encrypt_get(&on) == MCDE_SYS_OK)
printf("swap encrypted in swap: %s\n",
on ? "yes" : "no");
else
printf("swap (%s)\n", mcde_sys_error());
if (mcde_sys_firewall_get(&on, conf, sizeof conf) == MCDE_SYS_OK)
printf("firewall %s, %s\n", on ? "on" : "off", conf);
else
printf("firewall (%s)\n", mcde_sys_error());
n = mcde_sys_cgd_volumes(vols, 8);
if (n >= 0) {
printf("cgd %d volume%s\n", n, n == 1 ? "" : "s");
for (k = 0; k < n; k++)
printf(" %s\n", vols[k]);
} else
printf("cgd (%s)\n", mcde_sys_error());
}
if (failures == 0)
printf("PASS test_sysinfo\n");
return failures != 0;
+2 -1
View File
@@ -7,7 +7,8 @@ bin_PROGRAMS = dtsystemsettings
dtsystemsettings_SOURCES = main.c panes.c panes.h ui.h accounts.c update.c \
network.c \
input.c appearance.c desktop.c timezone.c wifi.c \
startup.c sharing.c backup.c displays.c language.c sound.c
startup.c sharing.c backup.c displays.c language.c sound.c \
security.c
dtsystemsettings_CPPFLAGS = -I$(top_srcdir)/include $(DT_INCDIR) \
-I$(top_builddir)/include $(XFT_CFLAGS) \
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\" \
+3 -1
View File
@@ -1110,8 +1110,10 @@ MakeInput(Widget parent, const char *which)
tabs = XtVaCreateManagedWidget("inputTabs", xmRowColumnWidgetClass,
box, XmNorientation, XmHORIZONTAL, XmNspacing, 4,
XmNmarginWidth, 0, NULL);
/* vertical: a child of a vertical row column would pack its pages
* side by side (the default is the parent's orientation reversed) */
pages = XtVaCreateManagedWidget("inputPages", xmRowColumnWidgetClass,
box, XmNspacing, 4, NULL);
box, XmNorientation, XmVERTICAL, XmNspacing, 4, NULL);
for (i = 0; i < 3; i++) {
XmString s = XmStringCreateLocalized((char *) labels[i]);
Widget t = XtVaCreateManagedWidget("inputTab",
+4
View File
@@ -1040,6 +1040,10 @@ ShowPane(const Pane *p)
XtDestroyWidget(current);
if (strcmp(p->id, "sound") == 0)
w = MakeSound(paneArea);
else if (strcmp(p->id, "security") == 0) {
w = MakeSecurity(paneArea);
XtVaSetValues(shell, XmNheight, 620, XmNwidth, 700, NULL);
}
else if (strcmp(p->id, "network") == 0)
w = MakeNetwork(paneArea);
else if (strcmp(p->id, "bluetooth") == 0)
+3 -2
View File
@@ -31,8 +31,9 @@ const Pane panes[] = {
NULL, "language sprache locale region formats datum" },
{ "dock", "Dock", CAT_PERSONAL, "DtPanel.m.pm", PANE_LATER, NULL,
"dock leiste panel front panel" },
{ "security", "Security", CAT_PERSONAL, "Dtlockscrn.pm", PANE_LATER,
NULL, "security sicherheit firewall lock sperre" },
{ "security", "Security", CAT_PERSONAL, "McdeLock.pm", PANE_OWN, NULL,
"security sicherheit firewall lock sperre password passwort "
"encryption verschluesselung cgd swap virtual memory npf" },
{ "sound", "Sound", CAT_HARDWARE, "Dtaudio.m.pm", PANE_OWN, NULL,
"sound audio lautstaerke volume ton" },
+358
View File
@@ -0,0 +1,358 @@
/*
* security.c -- dtsystemsettings: the computer's security (t0157)
*
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
*
* Three tabs as the reference has them: General, Encryption, Firewall.
*
* General "Require password to wake this computer from sleep or
* screen saver" is dtsession's lock time (SmStateInfo,
* smLockTimeout; the Screen Saver page shows the same value --
* one setting, two pages). With the lock at the saver's time,
* dtsession locks the screen when the saver starts and needs
* the password to come back. "Use secure virtual memory" is
* NetBSD's vm.swap_encrypt through McdeSys; it needs the
* administrator. Automatic login and a log-out after some
* minutes of inactivity are shown with what the desktop can
* do today: dtlogin always asks, dtsession has no idle logout.
* Encryption the cgd(4) volumes of /etc/cgd/cgd.conf (McdeSys); making
* one is an install-time decision, so the page shows and does
* not change.
* Firewall the state of NetBSD's npf(7) (rc.conf npf=YES, its file);
* the page reads, the rules are a follow-up.
*
* C99, POSIX, Xt and Motif only (ext/src/mcde/AGENTS.md).
*/
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Intrinsic.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/List.h>
#include <Xm/RowColumn.h>
#include <Xm/Scale.h>
#include <Xm/ToggleB.h>
#include <Dt/SessionM.h>
#include <Mcde/McdeSys.h>
#include "ui.h"
static Widget genLock, genLockNote, genSwap, genSwapNote;
static Widget genLogout, genLogoutNote;
/* ---- the session manager's lock time ------------------------------------ */
static int
SessionState(Display *dpy, SmStateInfo *st)
{
Window sm = None;
memset(st, 0, sizeof *st);
if (_DtGetSmWindow(dpy, RootWindow(dpy, 0), &sm) != Success)
return 0;
if (_DtGetSmState(dpy, sm, st) != Success)
return 0;
return 1;
}
/* dtsession's lock time: 0 is no lock */
static void
LockRead(Widget w)
{
Display *dpy = XtDisplay(w);
SmStateInfo st;
if (!SessionState(dpy, &st)) {
/* not dead: the session manager may come later (a login);
* the change handler asks again */
XmToggleButtonSetState(genLock, False, False);
SetText(genLockNote, "No session manager runs at the moment; "
"a change is kept when one does.");
return;
}
XmToggleButtonSetState(genLock, st.smLockTimeout > 0, False);
}
/* on: lock when the saver starts (or after ten minutes without one);
* off: no lock */
static void
LockChanged(Widget w, XtPointer data, XtPointer call)
{
Display *dpy = XtDisplay(w);
SmStateInfo st;
Window sm = None;
Boolean on = XmToggleButtonGetState(genLock);
(void) data;
(void) call;
if (_DtGetSmWindow(dpy, RootWindow(dpy, 0), &sm) != Success) {
SetText(genLockNote, "No session manager runs, so the lock "
"was not set.");
return;
}
memset(&st, 0, sizeof st);
/* only this field: the saver's own time stays as it is */
st.flags = SM_STATE_LOCKTIMEOUT;
st.smLockTimeout = 0;
if (on) {
SmStateInfo now;
st.smLockTimeout = 600; /* ten minutes without a saver */
if (SessionState(dpy, &now) && now.smSaverTimeout > 0)
st.smLockTimeout = now.smSaverTimeout;
}
if (_DtSetSmState(dpy, sm, &st) != Success)
SetText(genLockNote, "The session manager did not take it.");
else
SetText(genLockNote, on ? "The screen locks when the saver "
"starts (or after ten minutes without one)." :
"The screen does not lock.");
XFlush(dpy);
}
/* ---- secure virtual memory ---------------------------------------------- */
static void
SwapRead(Widget w)
{
int on = 0;
int r = mcde_sys_swap_encrypt_get(&on);
if (r != MCDE_SYS_OK) {
XmToggleButtonSetState(genSwap, False, False);
XtSetSensitive(genSwap, False);
SetText(genSwapNote, mcde_sys_error());
return;
}
XmToggleButtonSetState(genSwap, on != 0, False);
SetText(genSwapNote, "The swap's pages are encrypted with a key that "
"is only in memory.");
}
static void
SwapChanged(Widget w, XtPointer data, XtPointer call)
{
Boolean on = XmToggleButtonGetState(genSwap);
int r = mcde_sys_swap_encrypt_set(on);
(void) w;
(void) data;
(void) call;
if (r != MCDE_SYS_OK) {
SetText(genSwapNote, mcde_sys_error());
/* the state the system really has */
SwapRead(genSwap);
return;
}
SetText(genSwapNote, on ? "Encrypted from now on, and after the next "
"start." : "Not encrypted any more, from the next start.");
}
/* ---- the pages ---------------------------------------------------------- */
static Widget
GeneralPage(Widget parent)
{
Widget page = XtVaCreateWidget("securityGeneral",
xmRowColumnWidgetClass, parent, XmNspacing, 8, NULL);
Widget row, l;
genLock = XtVaCreateManagedWidget("Require password to wake this "
"computer from sleep or screen saver",
xmToggleButtonWidgetClass, page, NULL);
XtAddCallback(genLock, XmNvalueChangedCallback, LockChanged, NULL);
genLockNote = Text(page, "lockNote", "");
(void) Text(page, "accountsLabel", "For all accounts on this "
"computer:");
row = XtVaCreateManagedWidget("accountsRow",
xmRowColumnWidgetClass, page, XmNorientation, XmVERTICAL,
XmNspacing, 2, XmNmarginLeft, 18, XmNmarginWidth, 0, NULL);
{
Widget autoLogin;
autoLogin = XtVaCreateManagedWidget(
"Disable automatic login", xmToggleButtonWidgetClass,
row, NULL);
XmToggleButtonSetState(autoLogin, True, False);
XtSetSensitive(autoLogin, False);
(void) Text(row, "autoNote", "dtlogin has no automatic login: "
"it always asks for a name and a password.");
}
{
Widget after = XtVaCreateManagedWidget("logoutRow",
xmRowColumnWidgetClass, row, XmNorientation,
XmHORIZONTAL, XmNspacing, 6, XmNmarginWidth, 0, NULL);
genLogout = XtVaCreateManagedWidget("Log out after minutes "
"of inactivity", xmToggleButtonWidgetClass, after,
NULL);
XtSetSensitive(genLogout, False);
l = XtVaCreateManagedWidget("logoutMinutes",
xmScaleWidgetClass, row, XmNorientation, XmHORIZONTAL,
XmNminimum, 5, XmNmaximum, 120, XmNvalue, 60,
XmNshowValue, True, XmNscaleWidth, 240, NULL);
XtSetSensitive(l, False);
(void) after;
genLogoutNote = Text(row, "logoutNote", "dtsession has no "
"log-out after inactivity yet; the setting waits for it.");
}
genSwap = XtVaCreateManagedWidget("Use secure virtual memory",
xmToggleButtonWidgetClass, page, NULL);
XtAddCallback(genSwap, XmNvalueChangedCallback, SwapChanged, NULL);
genSwapNote = Text(page, "swapNote", "");
LockRead(page);
SwapRead(page);
(void) row;
return page;
}
static Widget
EncryptionPage(Widget parent)
{
Widget page = XtVaCreateWidget("securityEncryption",
xmRowColumnWidgetClass, parent, XmNspacing, 8, NULL);
char vols[16][MCDE_SYS_CGD_ENTRY_LEN];
int n, i;
(void) Text(page, "cgdLabel", "Encrypted disks (cgd):");
n = mcde_sys_cgd_volumes(vols, 16);
if (n < 0) {
(void) Text(page, "cgdNone", mcde_sys_error());
} else if (n == 0) {
(void) Text(page, "cgdNone", "No encrypted disk is "
"configured (/etc/cgd/cgd.conf is empty).");
} else {
Widget list = XmCreateScrolledList(page, "cgdVolumes", NULL, 0);
for (i = 0; i < n; i++) {
XmString s = XmStringCreateLocalized(vols[i]);
XmListAddItemUnselected(list, s, 0);
XmStringFree(s);
}
XtManageChild(list);
}
(void) Text(page, "encryptNote", "Encrypting a disk is a decision of "
"the installation (sysinst): a running system");
(void) Text(page, "encryptNote2", "does not convert one. This page "
"shows what is encrypted; changing a cgd");
(void) Text(page, "encryptNote3", "passphrase is a follow-up.");
return page;
}
static Widget
FirewallPage(Widget parent)
{
Widget page = XtVaCreateWidget("securityFirewall",
xmRowColumnWidgetClass, parent, XmNspacing, 8, NULL);
char conf[128], line[256];
int on = 0;
(void) Text(page, "firewallLabel", "The packet filter (npf):");
if (mcde_sys_firewall_get(&on, conf, sizeof conf) != MCDE_SYS_OK) {
(void) Text(page, "firewallNone", mcde_sys_error());
} else {
(void)snprintf(line, sizeof line, "%s, configuration %s",
on ? "on: started at boot (npf=YES in /etc/rc.conf)" :
"off (npf=YES is not in /etc/rc.conf)", conf);
(void) Text(page, "firewallState", line);
}
(void) Text(page, "firewallNote", "Three modes as the reference has "
"them: all incoming, the shared services,");
(void) Text(page, "firewallNote2", "or a list of services. Writing "
"the rules is a follow-up: a fixed template");
(void) Text(page, "firewallNote3", "with the shares of the Sharing "
"page (SSH, SMB, AFP, NFS), never free text;");
(void) Text(page, "firewallNote4", "\"npfctl reload\" needs the "
"administrator.");
return page;
}
/* ---- the pane: three tabs ---------------------------------------------- */
static Widget secBox, secContent;
static int secShown = -1;
static void
ShowSecurityPage(int which)
{
if (secContent != NULL) {
XtDestroyWidget(secContent);
secContent = NULL;
}
genLock = genSwap = NULL;
secShown = which;
if (which == 1)
secContent = EncryptionPage(secBox);
else if (which == 2)
secContent = FirewallPage(secBox);
else
secContent = GeneralPage(secBox);
/* a page built while it was unmanaged keeps a height of one line when
* it is managed afterwards (measured); building it fresh and managing
* it at once lays it out as the first one */
XtManageChild(secContent);
}
static void
SecurityTab(Widget w, XtPointer data, XtPointer call)
{
int which = (int) (size_t) data;
(void) w;
if (call != NULL && !((XmToggleButtonCallbackStruct *) call)->set)
return;
if (which != secShown)
ShowSecurityPage(which);
}
Widget
MakeSecurity(Widget parent)
{
/* vertical, said out loud: a row column inside the pane area (which
* is vertical) would otherwise take the other direction */
Widget box = XtVaCreateWidget("security", xmRowColumnWidgetClass,
parent, XmNorientation, XmVERTICAL, XmNspacing, 8, NULL);
Widget tabs;
static const char *const labels[3] = { "General", "Encryption",
"Firewall" };
int i;
tabs = XtVaCreateManagedWidget("securityTabs", xmRowColumnWidgetClass,
box, XmNorientation, XmHORIZONTAL, XmNspacing, 4,
XmNmarginWidth, 0, XmNradioBehavior, True, NULL);
for (i = 0; i < 3; i++) {
XmString s = XmStringCreateLocalized((char *) labels[i]);
Widget t = XtVaCreateManagedWidget("securityTab",
xmToggleButtonWidgetClass, tabs, XmNlabelString, s,
XmNindicatorOn, False, XmNshadowThickness, 2,
XmNfillOnSelect, True, XmNmarginWidth, 10, NULL);
XmStringFree(s);
XtAddCallback(t, XmNvalueChangedCallback, SecurityTab,
(XtPointer) (size_t) i);
}
/* the pages' own container: one column, so the page rebuilt on a tab
* change takes the slot under the tabs (a tight-packed row column
* would put a new child into the next column) */
secBox = XtVaCreateManagedWidget("securityPages",
xmRowColumnWidgetClass, box, XmNorientation, XmVERTICAL,
XmNpacking, XmPACK_COLUMN, XmNspacing, 4, XmNmarginWidth, 0,
NULL);
ShowSecurityPage(0);
{
Widget first = XtNameToWidget(tabs, "securityTab");
if (first != NULL)
XmToggleButtonSetState(first, True, False);
}
return box;
}
+3 -1
View File
@@ -336,8 +336,10 @@ MakeSound(Widget parent)
tabs = XtVaCreateManagedWidget("soundTabs", xmRowColumnWidgetClass,
box, XmNorientation, XmHORIZONTAL, XmNspacing, 4,
XmNmarginWidth, 0, NULL);
/* vertical: a child of a vertical row column would pack its pages
* side by side (the default is the parent's orientation reversed) */
pages = XtVaCreateManagedWidget("soundPages", xmRowColumnWidgetClass,
box, XmNspacing, 4, NULL);
box, XmNorientation, XmVERTICAL, XmNspacing, 4, NULL);
for (i = 0; i < 3; i++) {
XmString s = XmStringCreateLocalized((char *) labels[i]);
Widget t = XtVaCreateManagedWidget("soundTab",
+2
View File
@@ -69,6 +69,8 @@ Widget MakeLanguage(Widget parent);
Widget MakeInput(Widget parent, const char *which);
/* the Sound pane (sound.c): Sound Effects | Output | Input */
Widget MakeSound(Widget parent);
/* the Security pane (security.c): General | Encryption | Firewall */
Widget MakeSecurity(Widget parent);
/* the Displays pane (displays.c) and dtsystemsettings -apply-displays,
* ~/.dt/displays at login (Xsession.d/0071.displays) */
Widget MakeDisplays(Widget parent);
+1
View File
@@ -6,6 +6,7 @@ dist_icon_DATA = \
McdeDisk.l.pm \
McdeDisk.m.pm \
McdeDisk.t.pm \
McdeLock.pm \
DtScrn.t.pm \
McdeNetwork.l.pm \
McdeNetwork.m.pm \
+42
View File
@@ -0,0 +1,42 @@
/* XPM */
/* MCDE: McdeLock -- the Security pane (a padlock), 32x32 */
static char *McdeLock_pm[] = {
"32 32 6 1 0 0",
" s none m none c none",
". s iconColor1 c black m black",
"+ s iconColor2 c white m white",
"@ s iconGray3 m white c #adadadadadad",
"o s topShadowColor m white c #bdbdbdbdbdbd",
"J s bottomShadowColor m black c #636363636363",
" ",
" ",
" ",
" ",
" +++++++ ",
" +++++++++++ ",
" +++++++++++++ ",
" +++++ +++++ ",
" ++++ ++++ ",
" +++ +++ ",
" ++++ ++++ ",
" +++ +++ ",
" +++ +++ ",
" +oooooooooooooooJ++ ",
" o@@@@@@@@@@@@@@J ",
" o@@@@@@@@@@@@@@J ",
" o@@@@@@@@@@@@@@J ",
" o@@@@@@@.@@@@@@J ",
" o@@@@@@...@@@@@J ",
" o@@@@@.....@@@@J ",
" o@@@@@@...@@@@@J ",
" o@@@@@@..@@@@@@J ",
" o@@@@@@..@@@@@@J ",
" o@@@@@@..@@@@@@J ",
" o@@@@@@..@@@@@@J ",
" o@@@@@@@@@@@@@@J ",
" o@@@@@@@@@@@@@@J ",
" oJJJJJJJJJJJJJJJ ",
" ",
" ",
" ",
" "};