mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 05:40:15 +01:00
We no longer add these. If you use Emacs, configure it yourself.
Also, due to our "smart-tab" usage the editor anyway does a subpar
job handling our tabs. However, on the upside every user can choose
whatever tab-width he/she prefers. If "smart-tabs" are used properly
(like we do), every tab-width will work.
No manual changes, just ran commands:
F=($(git grep -l -e '-\*-'))
sed '1 { /\/\* *-\*- *[mM]ode.*\*\/$/d }' -i "${F[@]}"
sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}"
Check remaining lines with:
git grep -e '-\*-'
The ultimate purpose of this is to cleanup our files and eventually use
SPDX license identifiers. For that, first get rid of the boilerplate lines.
72 lines
2.2 KiB
Python
Executable file
72 lines
2.2 KiB
Python
Executable file
#!/usr/bin/env python
|
|
|
|
from gi.repository import GLib
|
|
import sys
|
|
import dbus
|
|
import dbus.service
|
|
import dbus.mainloop.glib
|
|
|
|
IFACE_SECRET_AGENT = 'org.freedesktop.NetworkManager.SecretAgent'
|
|
IFACE_AGENT_MANAGER = 'org.freedesktop.NetworkManager.AgentManager'
|
|
|
|
class NotAuthorizedException(dbus.DBusException):
|
|
_dbus_error_name = IFACE_SECRET_AGENT + '.NotAuthorized'
|
|
|
|
class Agent(dbus.service.Object):
|
|
def __init__(self, bus, object_path):
|
|
self.agents = {}
|
|
self.bus = bus
|
|
dbus.service.Object.__init__(self, bus, object_path)
|
|
|
|
@dbus.service.method(IFACE_SECRET_AGENT,
|
|
in_signature='a{sa{sv}}osasb',
|
|
out_signature='a{sa{sv}}',
|
|
sender_keyword='sender')
|
|
def GetSecrets(self, connection_hash, connection_path, setting_name, hints, request_new, sender=None):
|
|
if not sender:
|
|
raise NotAuthorizedException("Internal error: couldn't get sender")
|
|
uid = self.bus.get_unix_user(sender)
|
|
if uid != 0:
|
|
raise NotAuthorizedException("UID %d not authorized" % uid)
|
|
|
|
print("Secrets requested path '%s' setting '%s' hints '%s' new %d" % (connection_path, setting_name, str(hints), request_new))
|
|
|
|
# return some random GSM secrets
|
|
s_gsm = dbus.Dictionary({'password': 'asdfadfasdfaf'})
|
|
con = dbus.Dictionary({'gsm': s_gsm})
|
|
return con
|
|
|
|
def register(proxy):
|
|
proxy.Register("test.agent.id", dbus_interface=IFACE_AGENT_MANAGER)
|
|
print("Registered!")
|
|
return False
|
|
|
|
def unregister(proxy, loop):
|
|
proxy.Unregister(dbus_interface=IFACE_AGENT_MANAGER)
|
|
loop.quit()
|
|
return False
|
|
|
|
def main():
|
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
|
|
|
bus = dbus.SystemBus()
|
|
obj = Agent(bus, "/org/freedesktop/NetworkManager/SecretAgent")
|
|
proxy = bus.get_object("org.freedesktop.NetworkManager",
|
|
"/org/freedesktop/NetworkManager/AgentManager")
|
|
|
|
mainloop = GLib.MainLoop()
|
|
|
|
GLib.idle_add(register, proxy)
|
|
print("Running test secret agent")
|
|
|
|
try:
|
|
mainloop.run()
|
|
except KeyboardInterrupt:
|
|
pass
|
|
|
|
print("Unregistering...")
|
|
unregister(proxy, mainloop);
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|