[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: apt-setup bugs / patch review



Updated the patch file, inserted the code into the mirror section as seemed appropriate, fixed a rather obvious problem with my previous posted code.


On 12 May 2014 06:08, Christian PERRIER <bubulle@debian.org> wrote:
Quoting bofh80 (afm404@gmail.com):
> Something like this then? Now the idea i had in my head, was that this
> would just be preseeded with apt-setup/local0/netrc  etc. So that for the
> next repository, apt-setup/local1/netrc .

I the point is only to preseed information and not prompt users, then
templates shouldn't be marked as translatable.....but as we did most
of the work to make them translatable (and therefore envetually shown
to users, in expert mode), it'd be a shame to stop now.


> Template: apt-setup/local/netrc
> Type: boolean
> Default: false
> # :sl3:
> #flag:translate!:4
> _Description: Use authentication information for the APT server?:
>  You chose to use a mirror FTP server that doesn't allow anonymous
>  logins but allows authentication with local logins.
>  .
>  The needed credentials in the syntax described by netrc(5) need to be
> supplied.
>  In the following example, "<packages.example.org>" is the
>  mirror server host name, "<myuser>" is the login to use on this server
>  and "<mypass>" is the password for that login:
>  .
>   machine <packages.example.org> login <myuser> password <mypass>
>  .
>  This information will be stored in "/etc/apt/auth.conf" on the
>  installed machine.

Well, if users are prompted for individual components fot eh netrc
entry later on, we probably don't need to give the example.

Also, drop the colon after the quesiton mark in the template's synopsis.

Please find below the style rewrite of the templates to make them fit
the writing style usually used in most packages' debconf templates
(and D-I templates).

Please also note that I haven't reviewed the rest of the code which
needs to be wrapped around all this, particularly for the db_input handling.

Template: apt-setup/local/netrc
Type: boolean
Default: false
# :sl3:
#flag:translate!:4
_Description: Use authentication information for the APT server?
 You chose to use a mirror FTP server that doesn't allow anonymous
 logins but allows authentication with local logins.
 .
 The needed credentials, in the syntax described by netrc(5),
 need to be supplied. If you choose this option, you will be prompted
 for the server hostname and the needed credentials. This informaiton
 will be stored in /etc/apt/auth.conf as follow:
 .
  machine <packages.example.orglogin <myuserpassword <mypass>



Template: apt-setup/local/netrc/machine
Type: string
_Description: Host name of the mirror server:
 Please provide the host name for the APT mirror server that needs
 netrc-based authentication to be accessed.
 .
 Please see netrc(5) for details. This information will be stored in
 the /etc/apt/auth.conf file (only readable by root).

Template: apt-setup/local/netrc/username
Type: string
# :sl3:
_Description: Username to access the mirror server:
 Please provide the needed login name for the APT mirror server that needs
 netrc-based authentication to be accessed.
 .
 Please see netrc(5) for details. This information will be stored in
 the /etc/apt/auth.conf file (only readable by root).

Template: apt-setup/local/netrc/password
Type: password
# :sl3:
_Description: Password to access the mirror server:
 Please provide the needed password for the APT mirror server that needs
 netrc-based authentication to be accessed.
 .
 Please see netrc(5) for details. This information will be stored in
 the /etc/apt/auth.conf file (only readable by root).



From fee9ddbd2bd663e91409a2969b4e035b452d82e8 Mon Sep 17 00:00:00 2001
From: "Anthony F. McInerney" <afm404@gmail.com>
Date: Thu, 15 May 2014 02:52:19 +0100
Subject: [PATCH] Adding netrc to generate auth.conf

Signed-off-by: Anthony F. McInerney <afm404@gmail.com>
---
 debian/apt-mirror-setup.templates | 47 +++++++++++++++++++++++++++++++++++++++
 generators/50mirror               | 22 ++++++++++++++++++
 generators/60local                | 17 ++++++++++++++
 3 files changed, 86 insertions(+)

diff --git a/debian/apt-mirror-setup.templates b/debian/apt-mirror-setup.templates
index 62d9bbb..bb62cd4 100644
--- a/debian/apt-mirror-setup.templates
+++ b/debian/apt-mirror-setup.templates
@@ -60,3 +60,50 @@ _Description: Continue without a network mirror?
  .
  If you are installing from a netinst CD and choose not to use a mirror,
  you will end up with only a very minimal base system.
+
+Template: apt-setup/mirror/netrc
+Type: boolean
+Default: false
+# :sl3:
+#flag:translate!:4
+_Description: Use authentication information for the APT server?
+ You chose to use a repository or mirror server that doesn't allow anonymous
+ logins but allows authentication with local logins.
+ .
+ The required credentials, in the syntax described by netrc(5),
+ need to be supplied. If you choose this option, you will be prompted
+ for the server host name and the authentication credentials. This information
+ will be stored in /etc/apt/auth.conf (only readable by root) as follows:
+ .
+  machine <packages.example.orglogin <myuserpassword <mypass>
+
+Template: apt-setup/mirror/netrc/machine
+Type: string
+# :sl3:
+_Description: Host name of the APT server:
+ Please provide the host name for the APT repository or mirror server that needs
+ netrc-based authentication to be accessed.
+ .
+ Please see netrc(5) for details. This information will be stored in
+ the /etc/apt/auth.conf file (only readable by root).
+
+Template: apt-setup/mirror/netrc/username
+Type: string
+# :sl3:
+_Description: Username to access the APT server:
+ Please provide the needed login name for the APT repository or mirror server
+ that needs netrc-based authentication to be accessed.
+ .
+ Please see netrc(5) for details. This information will be stored in
+ the /etc/apt/auth.conf file (only readable by root).
+
+Template: apt-setup/mirror/netrc/password
+Type: password
+# :sl3:
+_Description: Password to access the APT server:
+ Please provide the needed password for the APT repository or mirror server that
+ needs netrc-based authentication to be accessed.
+ .
+ Please see netrc(5) for details. This information will be stored in
+ the /etc/apt/auth.conf file (only readable by root).
+ 
\ No newline at end of file
diff --git a/generators/50mirror b/generators/50mirror
index 4cb6bc4..876280c 100755
--- a/generators/50mirror
+++ b/generators/50mirror
@@ -212,6 +212,28 @@ if [ "$RET" = true ]; then
 fi
 
 done=""
+
+#APT authentication with netrc auth.conf
+db_input low "apt-setup/mirror/netrc"
+db_go
+if [ "$RET" = true ]; then
+	db_input low "apt-setup/mirror/netrc/machine"
+	db_go
+	db_get "apt-setup/mirror/netrc/machine"
+	netrcmachine="$RET"
+	db_input low "apt-setup/mirror/netrc/username"
+	db_go
+	db_get "apt-setup/mirror/netrc/username"
+	netrcusername="$RET"
+	db_input low "apt-setup/mirror/netrc/password"
+	db_go
+	db_get "apt-setup/mirror/netrc/password"
+	netrcpassword="$RET"
+	echo "machine $netrcmachine login $netrcusername password $netrcpassword" >> $ROOT/etc/apt/auth.conf
+	db_unregister "apt-setup/mirror/netrc/password"
+	chown 600 $ROOT/etc/apt/auth.conf
+fi
+
 while [ ! "$done" ]; do
 	db_get mirror/codename
 	codename="$RET"
diff --git a/generators/60local b/generators/60local
index fcd4f1c..0483d1e 100755
--- a/generators/60local
+++ b/generators/60local
@@ -51,6 +51,23 @@ while db_get "apt-setup/local$i/repository" && [ "$RET" ]; do
 			fi
 		done
 	fi
+	if db_get "apt-setup/local$i/netrc" && [ "$RET" = true ]; then
+		netrcmachine=
+		if db_get "apt-setup/local$i/netrc/machine"; then
+			netrcmachine="$RET"
+		fi
+		netrcusername=
+		if db_get "apt-setup/local$i/netrc/username"; then
+			netrcusername="$RET"
+		fi
+		netrcpassword=
+		if db_get "apt-setup/local$i/netrc/password"; then
+			netrcpassword="$RET"
+		fi
+		echo "machine $netrcmachine login $netrcusername password $netrcpassword" >> $ROOT/etc/apt/auth.conf
+		db_unregister "apt-setup/local$i/netrc/password"
+		chown 600 $ROOT/etc/apt/auth.conf
+	fi
 	i="$(($i + 1))"
 done
 
-- 
2.0.0.rc0


Reply to: