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.
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: