summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-dev/2012-November/019816.html
diff options
context:
space:
mode:
Diffstat (limited to 'zarb-ml/mageia-dev/2012-November/019816.html')
-rw-r--r--zarb-ml/mageia-dev/2012-November/019816.html177
1 files changed, 177 insertions, 0 deletions
diff --git a/zarb-ml/mageia-dev/2012-November/019816.html b/zarb-ml/mageia-dev/2012-November/019816.html
new file mode 100644
index 000000000..c1a06c011
--- /dev/null
+++ b/zarb-ml/mageia-dev/2012-November/019816.html
@@ -0,0 +1,177 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+ <HEAD>
+ <TITLE> [Mageia-dev] [soft-commits] [6416] Initial commit of Admin Panel.
+ </TITLE>
+ <LINK REL="Index" HREF="index.html" >
+ <LINK REL="made" HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20%5Bsoft-commits%5D%20%5B6416%5D%20Initial%20commit%20of%20Admin%0A%09Panel.&In-Reply-To=%3C50992DBC.9030808%40gmail.com%3E">
+ <META NAME="robots" CONTENT="index,nofollow">
+ <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
+ <LINK REL="Previous" HREF="019817.html">
+ <LINK REL="Next" HREF="019820.html">
+ </HEAD>
+ <BODY BGCOLOR="#ffffff">
+ <H1>[Mageia-dev] [soft-commits] [6416] Initial commit of Admin Panel.</H1>
+ <B>Matteo Pasotti</B>
+ <A HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20%5Bsoft-commits%5D%20%5B6416%5D%20Initial%20commit%20of%20Admin%0A%09Panel.&In-Reply-To=%3C50992DBC.9030808%40gmail.com%3E"
+ TITLE="[Mageia-dev] [soft-commits] [6416] Initial commit of Admin Panel.">matteo.pasotti at gmail.com
+ </A><BR>
+ <I>Tue Nov 6 16:33:16 CET 2012</I>
+ <P><UL>
+ <LI>Previous message: <A HREF="019817.html">[Mageia-dev] [soft-commits] [6416] Initial commit of Admin Panel.
+</A></li>
+ <LI>Next message: <A HREF="019820.html">[Mageia-dev] [soft-commits] [6416] Initial commit of Admin Panel.
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#19816">[ date ]</a>
+ <a href="thread.html#19816">[ thread ]</a>
+ <a href="subject.html#19816">[ subject ]</a>
+ <a href="author.html#19816">[ author ]</a>
+ </LI>
+ </UL>
+ <HR>
+<!--beginarticle-->
+<PRE>-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+On 06/11/2012 13:16, Guillaume Rousse wrote:
+&gt;<i> information in every single file, whereas a single top-level README
+</I>&gt;<i> file would be enough.
+</I>&gt;<i>
+</I>Hello Guillaume,
+
+GPLv2 says:
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the &quot;copyright&quot; line and a pointer to where the full
+notice is found.
+
+<A HREF="http://www.gnu.org/licenses/gpl-2.0.html">http://www.gnu.org/licenses/gpl-2.0.html</A>
+
+&gt;&gt;<i> + +package Auth;
+</I>&gt;<i> I'm convinced tough than using a shared top-level namespace, for
+</I>&gt;<i> instance AdminPanel or Mageia::AdminPanel, would be a better idea
+</I>&gt;<i> to express the idea than this module is a part of a software, than
+</I>&gt;<i> a loose comment such as &quot;This file is part of mcc2&quot;. package
+</I>&gt;<i> Mageia::AdminPanel::Auth;
+</I>&gt;<i>
+</I>It's just a prototype, it will be &quot;fixed&quot; in future.
+&gt;&gt;<i> + +require Exporter; <A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">+ at ISA</A> = qw(Exporter);
+</I>&gt;<i> You'd rather use a modern perl idiom: use base qw(Exporter)
+</I>&gt;<i>
+</I>&gt;<i> or
+</I>&gt;<i>
+</I>&gt;<i> use parent qw(Exporter);
+</I>&gt;<i>
+</I>Got it.
+&gt;&gt;<i> <A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">+ at EXPORT</A> = qw(require_root_capability +
+</I>&gt;&gt;<i> ask_for_authentication); + +use strict; +use warnings; +use
+</I>&gt;&gt;<i> diagnostics;
+</I>&gt;<i> Those pragmas should come first, before package variables
+</I>&gt;<i>
+</I>Got it
+&gt;&gt;<i> +use Data::Dumper;
+</I>&gt;<i> Unused anywere. Don't load debug-related modules in production
+</I>&gt;<i> coed.
+</I>&gt;<i>
+</I>afaik, apanel is not &quot;in production&quot; so what's your concern?.
+&gt;&gt;<i> +sub require_root_capability { + return 0 if(!$&gt;); + return
+</I>&gt;&gt;<i> 1; +}
+</I>&gt;<i> Perl best practice: use english name for magic variables, for
+</I>&gt;<i> readability:
+</I>&gt;<i>
+</I>&gt;<i> use English qw(-no_match_vars ); return 0 if (!$EUID);
+</I>&gt;<i>
+</I>&gt;<i> And your condition could be expressed in a single statement: sub
+</I>&gt;<i> require_root_capability { return $EUID == 0; }
+</I>&gt;<i>
+</I>&gt;&gt;<i> + +sub ask_for_authentication { + my @args = @ARGV; + my
+</I>&gt;&gt;<i> $command = wrap_command($0); + unshift(@args, $command-&gt;[2]);
+</I>&gt;&gt;<i> + exec { $command-&gt;[0] } $command-&gt;[1], @args or die (&quot;command
+</I>&gt;&gt;<i> %s missing&quot;, $command-&gt;[0]); + die &quot;You must be root to run
+</I>&gt;&gt;<i> this program&quot; if $&gt;; +}
+</I>&gt;<i> You're duplicating the condition from previous function here. die
+</I>&gt;<i> &quot;You must be root to run this program&quot; if
+</I>&gt;<i> !require_root_capability();
+</I>&gt;<i>
+</I>Don't blame me too much for readability and duplications, please.
+I was inspired by /usr/lib/libDrakX/common.pm and other modules that
+are not very readable and that contain similar duplications.
+Again, this module it's still a prototype and I'm learning new stuff
+while coding it. I'll work on improving its readability.
+&gt;<i> Morevoer, you'd better test before executing the command: die &quot;You
+</I>&gt;<i> must be root to run this program&quot; if !require_root_capability();
+</I>&gt;<i> exec { $command-&gt;[0] } $command-&gt;[1], @args or die (&quot;command %s
+</I>&gt;<i> missing&quot;, $command-&gt;[0]);
+</I>&gt;<i>
+</I>Same as above, take a look at /usr/lib/libDrakX/common.pm and you'll
+see that the test is performed after the exec.
+&gt;&gt;<i> +sub wrap_command { + my $currenv = &quot;env&quot;; + my $wrapper =
+</I>&gt;&gt;<i> &quot;pkexec&quot;; + my $app = $0; + my $command = [$wrapper,
+</I>&gt;&gt;<i> $currenv, $app]; + ($command); +}
+</I>&gt;<i> Perl best practice: use explicit return statement, for better
+</I>&gt;<i> readability: return ($command);
+</I>&gt;<i>
+</I>Again, same as above.
+&gt;<i> Using temporary variables for constant isn't very useful here, the
+</I>&gt;<i> whole function would probably be more readable this way:
+</I>&gt;<i>
+</I>&gt;<i> sub wrap_command { my ($app) = @_; return (['pkexec', 'env',
+</I>&gt;<i> $app]); }
+</I>&gt;<i>
+</I>&gt;<i> I don't understand the need for list contexte here, tough.
+</I>&gt;<i>
+</I>&gt;<i> BTW, your indentation isn't consistent between various files.
+</I>I worked almost exclusively on the file you have dissected =) and
+honestly it's not a big issue to me to read source files with
+different indentations (I mean if they are somehow indented and
+readable).
+
+I'll try to improve my code even paying attention to your precious
+advices.
+
+Thank you.
+
+Matteo
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.12 (GNU/Linux)
+Comment: Using GnuPG with Mozilla - <A HREF="http://enigmail.mozdev.org/">http://enigmail.mozdev.org/</A>
+
+iQEcBAEBAgAGBQJQmS25AAoJED3LowjDDWbNj3MH/jazMliy7g+VmvYYm5EA2t3G
+nqv4o3+FT01cRp45OXq+Xus7TIg/IEFDAtfsIRfWUWH7sH7J1ooWywzourD4kkj0
+XXWw7Wykhhpn2cJ5Sv55KwAr5u+ubt5CC2Tga7sis3hvcsFuMKXOoxV6BtUIUQ4O
++IuzybR7GhjM/B+oGiPdSLQyRXEB/LhxWsle+Xs0Ode5dYjLZ3QR4YumVC6YiYsS
+qU/B9SYd3P09K48zqjWNtxDfwf8QItU5oCZ8p9nFnY3vLkW16FGiG2MFJigrOfjq
++Ae+6qH/Q/ZH3iqoZDBGXutr6zUIHhyJmU6ICawR2IIbj6lGdKxTUjqu3aN0H+o=
+=U5sK
+-----END PGP SIGNATURE-----
+</PRE>
+
+
+
+
+
+
+
+
+
+<!--endarticle-->
+ <HR>
+ <P><UL>
+ <!--threads-->
+ <LI>Previous message: <A HREF="019817.html">[Mageia-dev] [soft-commits] [6416] Initial commit of Admin Panel.
+</A></li>
+ <LI>Next message: <A HREF="019820.html">[Mageia-dev] [soft-commits] [6416] Initial commit of Admin Panel.
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#19816">[ date ]</a>
+ <a href="thread.html#19816">[ thread ]</a>
+ <a href="subject.html#19816">[ subject ]</a>
+ <a href="author.html#19816">[ author ]</a>
+ </LI>
+ </UL>
+
+<hr>
+<a href="https://www.mageia.org/mailman/listinfo/mageia-dev">More information about the Mageia-dev
+mailing list</a><br>
+</body></html>