Merge lp:~pwlars/phablet-tools/network-no-sudo into lp:phablet-tools

Proposed by Paul Larson
Status: Merged
Approved by: Oliver Grawert
Approved revision: 318
Merged at revision: 320
Proposed branch: lp:~pwlars/phablet-tools/network-no-sudo
Merge into: lp:phablet-tools
Diff against target: 17 lines (+5/-2)
1 file modified
phablet-network (+5/-2)
To merge this branch: bzr merge lp:~pwlars/phablet-tools/network-no-sudo
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+235689@code.launchpad.net

Commit message

Don't use sudo in phablet-network unless it's really needed

Description of the change

We're trying to eliminate the sources of sudo needed in the ci testing process. In this case, even if you specify a network file for phablet-network to use and you have full permissions on it, phablet-network uses sudo to grep for the lines it needs from it unnecessarily. This fixes that so that it should only use sudo if the file is unreadable by the current user.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phablet-network'
2--- phablet-network 2014-09-18 11:45:03 +0000
3+++ phablet-network 2014-09-23 18:10:40 +0000
4@@ -128,8 +128,11 @@
5
6 echo Network file is $network_file
7
8- SSID="$(sudo grep ^ssid= "$network_file"|sed 's/^ssid=//')"
9- KEY="$(sudo grep ^psk= "$network_file"|sed 's/^psk=//')"
10+ if [ ! -r "$network_file" ]; then
11+ SUDO="sudo"
12+ fi
13+ SSID="$($SUDO grep ^ssid= "$network_file"|sed 's/^ssid=//')"
14+ KEY="$($SUDO grep ^psk= "$network_file"|sed 's/^psk=//')"
15
16 # No PSK ? Let's check for WEP
17 [ -z "$KEY" ] && KEY="$(sudo grep ^wep-key0= "$network_file"|sed 's/^wep-key0=//')"

Subscribers

People subscribed via source and target branches