From: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Date: Sat, 14 May 2022 02:52:50 +0800
Subject: _useradd-O_option

Goal: accepts the -O flag for backward compatibility. (was used by adduser?)
Note: useradd.8 needs to be regenerated.

Status wrt upstream: not included as this is just specific 
                     backward compatibility for Debian
---
 man/useradd.8.xml | 5 +++++
 src/useradd.c     | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/man/useradd.8.xml b/man/useradd.8.xml
index b458912..ddee46c 100644
--- a/man/useradd.8.xml
+++ b/man/useradd.8.xml
@@ -341,6 +341,11 @@
 	    databases are reset to avoid reusing the entry from a previously
 	    deleted user.
 	  </para>
+          <para>
+            For the compatibility with previous Debian's
+            <command>useradd</command>, the <option>-O</option> option is
+            also supported.
+          </para>
 	</listitem>
       </varlistentry>
       <varlistentry>
diff --git a/src/useradd.c b/src/useradd.c
index a679392..7107137 100644
--- a/src/useradd.c
+++ b/src/useradd.c
@@ -1143,9 +1143,9 @@ static void process_flags (int argc, char **argv)
 		};
 		while ((c = getopt_long (argc, argv,
 #ifdef WITH_SELINUX
-		                         "b:c:d:De:f:g:G:hk:K:lmMNop:rR:P:s:u:UZ:",
+		                         "b:c:d:De:f:g:G:hk:O:K:lmMNop:rR:P:s:u:UZ:",
 #else				/* !WITH_SELINUX */
-		                         "b:c:d:De:f:g:G:hk:K:lmMNop:rR:P:s:u:U",
+		                         "b:c:d:De:f:g:G:hk:O:K:lmMNop:rR:P:s:u:U",
 #endif				/* !WITH_SELINUX */
 		                         long_options, NULL)) != -1) {
 			switch (c) {
@@ -1274,6 +1274,7 @@ static void process_flags (int argc, char **argv)
 				kflg = true;
 				break;
 			case 'K':
+			case 'O': /* compatibility with previous Debian useradd */
 				/*
 				 * override login.defs defaults (-K name=value)
 				 * example: -K UID_MIN=100 -K UID_MAX=499
