ygini / Hello-IT

Self support apps provided by IT services to end users.
BSD 3-Clause "New" or "Revised" License
286 stars 32 forks source link

sudo networksetup -setairportpower doesn't work #46

Closed ofirgalcon closed 4 years ago

ofirgalcon commented 5 years ago

Setup info

Hello-IT version: 1.4.2 macOS version: any Preferences deployed via: dropped plist Preferences targeting: device

Setup goal

Restart WiFi from a menu item

Issue description

I created a custom script

function restartWifi {
    sudo networksetup -setairportpower "Wi-Fi" off
    sleep 1
    sudo networksetup -setairportpower "Wi-Fi" on
    afplay /System/Library/Sounds/Blow.aiff 
}

Related logs

Filtering the log data using "processImagePath ENDSWITH "Hello IT""
Timestamp                       Thread     Type        Activity             PID    TTL  
2019-02-23 20:05:43.959136+0000 0x3310b54  Debug       0x0                  50489  Hello IT: (CoreFoundation) [com.apple.CFBundle:strings] Bundle: <private>, key: AXMenu, value: (null), table: RoleDescriptions, localizationName: (null), result: menu
2019-02-23 20:05:43.959363+0000 0x3310b54  Debug       0x0                  50489  Hello IT: (CoreFoundation) [com.apple.CFBundle:strings] Bundle: <private>, key: AXMenu, value: (null), table: RoleDescriptions, localizationName: (null), result: menu
2019-02-23 20:05:46.575431+0000 0x3310b54  Debug       0x0                  50489  Hello IT: (CoreFoundation) [com.apple.CFBundle:strings] Bundle: <private>, key: AXMenu, value: (null), table: RoleDescriptions, localizationName: (null), result: menu
2019-02-23 20:05:46.575813+0000 0x3310b54  Debug       0x0                  50489  Hello IT: (CoreFoundation) [com.apple.CFBundle:strings] Bundle: <private>, key: AXMenu, value: (null), table: RoleDescriptions, localizationName: (null), result: menu
2019-02-23 20:05:50.269083+0000 0x3310b54  Activity    0x1e59364            50489  Hello IT: (AppKit) perform action for menu item
2019-02-23 20:05:50.271630+0000 0x3310b54  Activity    0x1e59365            50489  Hello IT: (AppKit) sendAction:
2019-02-23 20:05:50.271965+0000 0x3310b54  Info        0x1e59365            50489  Hello IT: (ScriptedItem) Start script with command run
2019-02-23 20:05:53.069872+0000 0x380f905  Default     0x0                  50489  Hello IT: (CFNetwork) TIC TCP Conn Cancel [610:0x7fd071d42e00]
2019-02-23 20:05:53.069942+0000 0x380f905  Debug       0x0                  50489  Hello IT: (libnetwork.dylib) [com.apple.network:] tcp_connection_cancel 610
2019-02-23 20:05:53.070269+0000 0x380f905  Default     0x0                  50489  Hello IT: (libnetwork.dylib) [com.apple.network:] [616 <private> stream, pid: 50489, url: https://raw.githubusercontent.com/ygini/Hello-IT/975ff834701153c3a4cdf91991a9860334645eb9/staticfiles/internet_test.txt, tls] cancelled
    [616.1 D63CC7EC-2E5A-4D62-8CB1-8EE610A3094F <private>.60212<-><private>]
    Connected Path: satisfied (Path is satisfied), interface: en0, ipv4, dns
    Duration: 30.153s, DNS @0.000s took 0.041s, TCP @0.042s took 0.014s, TLS took 0.061s
    bytes in/out: 5621/681, packets in/out: 6/3, rtt: 0.012s, retransmitted packets: 0, out-of-order packets: 0
2019-02-23 20:05:53.070332+0000 0x380f905  Info        0x0                  50489  Hello IT: (libnetwork.dylib) [com.apple.network:] nw_endpoint_handler_cancel [616 raw.githubusercontent.com:443 ready resolver (satisfied)]
2019-02-23 20:05:53.070523+0000 0x380f905  Info        0x0                  50489  Hello IT: (libnetwork.dylib) [com.apple.network:] nw_endpoint_handler_cancel [616.1 151.101.16.133:443 ready socket-flow (satisfied)]
2019-02-23 20:05:53.070660+0000 0x380f905  Info        0x0                  50489  Hello IT: (libnetwork.dylib) [com.apple.network:] nw_endpoint_flow_protocol_disconnected [616.1 151.101.16.133:443 cancelled socket-flow (null)] Output protocol disconnected
2019-02-23 20:05:53.070692+0000 0x380f905  Debug       0x0                  50489  Hello IT: (libsystem_network.dylib) [com.apple.network:] nw_resolver_cancel 0x7fd06c5511c0
2019-02-23 20:05:53.070936+0000 0x380fd64  Activity    0x1e59366            50489  Hello IT: (Security) SecTrustReportTLSAnalytics
2019-02-23 20:05:53.071112+0000 0x380f905  Debug       0x0                  50489  Hello IT: (Security) [com.apple.securityd:handleobj] create 0x7fd06c6f61e6 for 0x7fd06c6f6530
2019-02-23 20:05:53.071159+0000 0x380f905  Debug       0x0                  50489  Hello IT: (Security) [com.apple.securityd:cssm] 0x7fd06c6f6530 attached module 0x7fd06c46c420(AppleCSP) (ssid 0 type 2)
2019-02-23 20:05:53.071438+0000 0x380f905  Debug       0x0                  50489  Hello IT: (Security) [com.apple.securityd:cssm] 0x7fd06c6f6530 detach module 0x7fd06c46c420(AppleCSP)
2019-02-23 20:05:53.071546+0000 0x380f905  Debug       0x0                  50489  Hello IT: (libnetwork.dylib) [com.apple.network:] -[NWConcrete_tcp_connection dealloc] 610
2019-02-23 20:05:54.049080+0000 0x380b8a0  Info        0x1e59365            50489  Hello IT: (ScriptedItem) Script exited with code 0

If possible, share the Hello-IT logs available in the console when this issue occurs.

Requested solution

Why doesn't it work?

ygini commented 5 years ago

Did you correctly managed your sudoers rights? Using sudo in a non interactive terminal (like when HIT run a script) require sudo to work without password.

For such request you should ask help on the #hello-it channel on MacAdmins' Slack.