Re: [PATCH] Comply with California AB 1043
Xylia Allegretta <[email protected]> Wed, 1 Apr 2026 23:37:25 +0000
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <CAE7GgQ80VuOqE05zxYXb4aKSWfW7sOGDw5__p9tpdkmXExe=oQ@mail.gmail.com> |
> We will lead the > charge on keeping children safe from text. To be honest, when I first read this email and looked over the patch, I was skeptical. As a foolish and vulnerable young person myself, I was worried that I might be seen as less cool if I have to admit my age just to edit my files. However, after looking it over, and trying out the patch for a bit... I feel so much safer and secure knowing that my age is being stored in a global variable until another prompt is made. So, thanks, Dad, for trying to keep me safe. Unfortunately, I fear that you might not have gone far enough. What if a kid tries to edit a file that they aren't ready for the responsibility of editing? That could be a disaster! So I have updated the patch to ensure this terrible nightmare situation never occurs. I can't wait until GNU nano 9.0 rolls out and we can rest easy at night knowing we thought of the children, with a feature like this included. -Xylia Allegretta.
thinkofthechildren-2.patch
(text/x-patch, 2.2 KB)
---
src/nano.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/src/nano.c b/src/nano.c
index 128af0b4..e15ba94d 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -26,6 +26,7 @@
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
+#include <time.h>
#ifdef __linux__
#include <sys/ioctl.h>
#endif
@@ -1736,6 +1737,7 @@ void process_a_keystroke(void)
int main(int argc, char **argv)
{
+ static time_t last_birthday = 20260401; /* Proper sentinel */
int stdin_flags, optchr;
#ifdef ENABLE_NANORC
bool ignore_rcfiles = FALSE;
@@ -2747,6 +2749,40 @@ int main(int argc, char **argv)
/* Forget any earlier cursor position at the prompt. */
put_cursor_at_end_of_answer();
+ /* If it's been awhile, make sure we get the user's birthday */
+ if (time(NULL) > last_birthday + 60) {
+ time_t birthtime;
+ char *abspath;
+ int response = do_prompt(MMAIN, "", NULL, edit_refresh,
+ /* TRANSLATORS: This is a prompt. */
+ /* Remember to ask with all the seriousness and logic that
+ went into the law */
+ _("Nevermind all that. Sorry, Cali made us ask, when is your birthday yo? (enter as unix time)"));
+ /* Using Unix Time for utmost precision and user convenience. */
+ last_birthday = time(NULL);
+ /* Get birthtime from prompt response. */
+ if(response || sscanf(answer, "%ld", &birthtime)!=1 || birthtime > last_birthday)
+ {
+ statusbar(_("Assuming you're a child, based on your lackluster response..."));
+ birthtime = last_birthday;
+ }
+ else
+ statusbar(_("Thank you for your cooperation."));
+ /* Don't allow children to edit sensitive files that could be dangerous. */
+ abspath = realpath(openfile->filename, NULL);
+ if(abspath && birthtime > last_birthday - 788400000l && strcmp(abspath, "/home"))
+ {
+ char *buf = malloc(birthtime*365*60*60*24*10000);
+ endwin();
+ fprintf(stderr, "Children shouldn't edit sensitive files!!\n\n");
+ fflush(stderr);
+ sprintf(buf, "Wait another %ld years!!", (last_birthday - birthtime + 788400000l)/31536000l);
+ fprintf(stderr, "%s\n", buf);
+ exit(1);
+ }
+ free(abspath);
+ }
+
/* Read in and interpret a single keystroke. */
process_a_keystroke();
}
--
2.52.0