summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord <d@openbsd.org>2000-01-08 23:23:37 +0000
committerd <d@openbsd.org>2000-01-08 23:23:37 +0000
commit15377c9bccf6805016fe63e41f454000bf92a0bf (patch)
tree79448c3b555ae6a6a52295203a171e9002203c57
parentsync with NetBSD (diff)
downloadwireguard-openbsd-15377c9bccf6805016fe63e41f454000bf92a0bf.tar.xz
wireguard-openbsd-15377c9bccf6805016fe63e41f454000bf92a0bf.zip
Allow UKC to change tz with 'timezone' command.
-rw-r--r--share/man/man8/boot_config.813
-rw-r--r--sys/kern/subr_userconf.c30
-rw-r--r--usr.sbin/config/cmd.c38
-rw-r--r--usr.sbin/config/cmd.h3
-rw-r--r--usr.sbin/config/ukc.h7
-rw-r--r--usr.sbin/config/ukcutil.c15
6 files changed, 94 insertions, 12 deletions
diff --git a/share/man/man8/boot_config.8 b/share/man/man8/boot_config.8
index f4c4694409d..ae2bcaf2455 100644
--- a/share/man/man8/boot_config.8
+++ b/share/man/man8/boot_config.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: boot_config.8,v 1.9 1999/07/09 13:35:36 aaron Exp $
+.\" $OpenBSD: boot_config.8,v 1.10 2000/01/08 23:23:37 d Exp $
.\"
.\" Copyright (c) 1996 Mats O Jansson
.\" All rights reserved.
@@ -56,6 +56,9 @@ using 430 buffers containing 1761280 bytes of memory
User Kernel Config
UKC>
.Ed
+.Pp
+Changes made can be saved for the next reboot, by using
+.Xr config 8 .
.Sh COMMANDS
.Bl -tag -width "disable devno | dev" indent
.It Ic add Ar dev
@@ -86,6 +89,11 @@ Show all devices for which attribute
.Ar attr
has the value
.Ar val .
+.It Ic timezone Op Ar minuteswest Op Ar dst
+Change the
+.Va tz
+timezone structure.
+Without arguments, displays its current value.
.It Ic verbose
Toggle the autoconfig verbose variable.
.El
@@ -201,10 +209,7 @@ commands.
Continuing...
mainbus0 (root)
.Ed
-.Pp
.Sh BUGS
The add command is rather restricted, and might be expanded in the future.
-.Pp
-There is no way to save the configuration for next boot.
.Sh AUTHOR
Mats O Jansson <moj@stacken.kth.se>
diff --git a/sys/kern/subr_userconf.c b/sys/kern/subr_userconf.c
index acfe9fba81d..d449812eef4 100644
--- a/sys/kern/subr_userconf.c
+++ b/sys/kern/subr_userconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_userconf.c,v 1.18 1999/10/04 20:04:31 deraadt Exp $ */
+/* $OpenBSD: subr_userconf.c,v 1.19 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
@@ -36,6 +36,7 @@
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
+#include <sys/time.h>
#include <dev/cons.h>
@@ -45,6 +46,7 @@ extern short cfroots[];
extern int cfroots_size;
extern int pv_size;
extern short pv[];
+extern struct timezone tz;
int userconf_base = 16; /* Base for "large" numbers */
int userconf_maxdev = -1; /* # of used device slots */
@@ -106,6 +108,7 @@ char *userconf_cmds[] = {
"lines", "L",
"quit", "q",
"show", "s",
+ "timezone", "t",
"verbose", "v",
"?", "h",
"", "",
@@ -644,6 +647,9 @@ userconf_help()
printf("[attr [val]] %s",
"show attributes (or devices with an attribute)");
break;
+ case 't':
+ printf("[mins [dst]] set timezone/dst");
+ break;
case 'v':
printf(" toggle verbose booting");
break;
@@ -1184,6 +1190,28 @@ userconf_parse(cmd)
else
userconf_show_attr(c);
break;
+ case 't':
+ if (*c == '\0' || userconf_number(c, &a) == 0) {
+ if (*c != '\0') {
+ tz.tz_minuteswest = a;
+ while (*c != '\n' && *c != '\t' &&
+ *c != ' ' && *c != '\0')
+ c++;
+ while (*c == '\t' || *c == ' ')
+ c++;
+ if (*c != '\0' &&
+ userconf_number(c, &a) == 0)
+ tz.tz_dsttime = a;
+ userconf_hist_cmd('t');
+ userconf_hist_int(tz.tz_minuteswest);
+ userconf_hist_int(tz.tz_dsttime);
+ userconf_hist_eoc();
+ }
+ printf("timezone = %d, dst = %d\n",
+ tz.tz_minuteswest, tz.tz_dsttime);
+ } else
+ printf("Unknown argument\n");
+ break;
case 'v':
autoconf_verbose = !autoconf_verbose;
printf("autoconf verbose %sabled\n",
diff --git a/usr.sbin/config/cmd.c b/usr.sbin/config/cmd.c
index d822f71ea51..26a1ecd4ffa 100644
--- a/usr.sbin/config/cmd.c
+++ b/usr.sbin/config/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.1 1999/10/04 20:00:50 deraadt Exp $ */
+/* $OpenBSD: cmd.c,v 1.2 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -30,13 +30,15 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: cmd.c,v 1.1 1999/10/04 20:00:50 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: cmd.c,v 1.2 2000/01/08 23:23:37 d Exp $";
#endif
+#include <ctype.h>
#include <stdio.h>
#include <limits.h>
#include <nlist.h>
#include <sys/device.h>
+#include <sys/time.h>
#include "misc.h"
#define CMD_NOEXTERN
#include "cmd.h"
@@ -56,6 +58,7 @@ cmd_table_t cmd_table[] = {
{"show", Xshow, "[attr [val]]\t", "Show attribute"},
{"exit", Xexit, "\t\t", "Exit, without saving changes"},
{"quit", Xquit, "\t\t", "Quit, saving current changes"},
+ {"timezone", Xtimezone, "[mins [dst]]\t", "Show/change timezone"},
{NULL, NULL, NULL, NULL}
};
@@ -254,3 +257,34 @@ Xexit(cmd)
/* Nothing to do here */
return (CMD_EXIT);
}
+
+int
+Xtimezone(cmd)
+ cmd_t *cmd;
+{
+ int num;
+ char *c;
+ struct timezone *tz =
+ (struct timezone *)adjust((caddr_t)nl[TZ_TZ].n_value);
+
+ if (strlen(cmd->args) == 0) {
+ printf("timezone = %d, dst = %d\n",
+ tz->tz_minuteswest, tz->tz_dsttime);
+ } else {
+ if (number(cmd->args, &num) == 0) {
+ tz->tz_minuteswest = num;
+ c = cmd->args;
+ while ((*c != '\0') && !isspace(*c))
+ c++;
+ while ((*c != '\0') && isspace(*c))
+ c++;
+ if (strlen(c) != 0 && number(c, &num) == 0)
+ tz->tz_dsttime = num;
+ printf("timezone = %d, dst = %d\n",
+ tz->tz_minuteswest, tz->tz_dsttime);
+ } else
+ printf("Unknown argument\n");
+ }
+
+ return (CMD_CONT);
+}
diff --git a/usr.sbin/config/cmd.h b/usr.sbin/config/cmd.h
index b6c972a5a87..032dfca605a 100644
--- a/usr.sbin/config/cmd.h
+++ b/usr.sbin/config/cmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.h,v 1.1 1999/10/04 20:00:50 deraadt Exp $ */
+/* $OpenBSD: cmd.h,v 1.2 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -71,6 +71,7 @@ int Xlist __P((cmd_t *));
int Xshow __P((cmd_t *));
int Xexit __P((cmd_t *));
int Xquit __P((cmd_t *));
+int Xtimezone __P((cmd_t *));
#endif _CMD_H
diff --git a/usr.sbin/config/ukc.h b/usr.sbin/config/ukc.h
index a042fddcd04..58883b20f3a 100644
--- a/usr.sbin/config/ukc.h
+++ b/usr.sbin/config/ukc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukc.h,v 1.1 1999/10/04 20:00:52 deraadt Exp $ */
+/* $OpenBSD: ukc.h,v 1.2 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -46,7 +46,8 @@
#define I_UEXTRALOC 11
#define I_HISTLEN 12
#define CA_HISTORY 13
-#define NLENTRIES 14
+#define TZ_TZ 14
+#define NLENTRIES 15
#ifdef UKC_MAIN
struct nlist nl[] = {
@@ -64,6 +65,7 @@ struct nlist nl[] = {
{ "_uextraloc" },
{ "_userconf_histlen" },
{ "_userconf_history" },
+ { "_tz" },
};
struct nlist knl[] = {
{ "_locnames" },
@@ -80,6 +82,7 @@ struct nlist knl[] = {
{ "_uextraloc" },
{ "_userconf_histlen" },
{ "_userconf_history" },
+ { "_tz" },
};
int maxdev = 0;
int totdev = 0;
diff --git a/usr.sbin/config/ukcutil.c b/usr.sbin/config/ukcutil.c
index 7c730194aab..456afbe04d3 100644
--- a/usr.sbin/config/ukcutil.c
+++ b/usr.sbin/config/ukcutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukcutil.c,v 1.1 1999/10/04 20:00:52 deraadt Exp $ */
+/* $OpenBSD: ukcutil.c,v 1.2 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -30,10 +30,11 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.1 1999/10/04 20:00:52 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.2 2000/01/08 23:23:37 d Exp $";
#endif
#include <sys/types.h>
+#include <sys/time.h>
#include <sys/device.h>
#include <limits.h>
#include <nlist.h>
@@ -1212,6 +1213,7 @@ process_history(len,buf)
char *c;
int devno,newno;
short unit,state;
+ struct timezone *tz;
if (len == 0) {
printf("History is empty\n");
@@ -1263,6 +1265,15 @@ process_history(len,buf)
enable(devno);
while (*c != '\n') c++; c++;
break;
+ case 't':
+ c++; c++;
+ tz = (struct timezone *)adjust((caddr_t)nl[TZ_TZ].
+ n_value);
+ tz->tz_minuteswest = atoi(c);
+ while (*c != ' ') c++; c++;
+ tz->tz_dsttime = atoi(c);
+ while (*c != '\n') c++; c++;
+ break;
case 'q':
while (*c != NULL) c++;
break;