├── PLIST ├── src ├── .gitignore ├── etc.defaults │ ├── config.json │ └── permissions.json ├── SimplePermissionManager.png ├── icon │ └── flaticon-approved-512.png ├── app │ ├── helptoc.conf │ ├── texts │ │ ├── chs │ │ │ └── strings │ │ └── enu │ │ │ └── strings │ ├── help │ │ └── enu │ │ │ └── SimplePermissionManager_index.html │ ├── config │ └── SimplePermissionManager.js ├── bin │ ├── spm-update │ ├── init-permision.py │ └── spm-update.sig ├── wizard │ ├── install_uifile_chs │ └── install_uifile ├── cmd │ ├── audit │ │ ├── db.go │ │ ├── reason.go │ │ └── audit.go │ ├── go.mod │ ├── parse_test.go │ ├── go.sum │ └── spm-exec.go ├── service-setup.sh ├── cgi │ ├── config.cgi │ ├── list-audit-logs.cgi │ ├── update-user.cgi │ ├── update-package.cgi │ ├── list-users.cgi │ ├── status.cgi │ └── list-packages.cgi └── conf │ └── resource ├── .gitignore ├── docs └── images │ ├── spm-installation-01.png │ ├── spm-installation-02.png │ ├── spm-installation-03.png │ ├── spm-installation-04.png │ ├── spm-installation-05.png │ └── spm-installation-06.png ├── .github └── workflows │ └── ci.yml ├── Makefile ├── README.md └── LICENSE /PLIST: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | bin/spm-exec 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | work-* 2 | build*log 3 | packages 4 | -------------------------------------------------------------------------------- /src/etc.defaults/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "trustSignature": true 3 | } -------------------------------------------------------------------------------- /src/etc.defaults/permissions.json: -------------------------------------------------------------------------------- 1 | { 2 | "users": {}, 3 | "packages": {} 4 | } -------------------------------------------------------------------------------- /src/SimplePermissionManager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPEnology-Community/SimplePermissionManager/HEAD/src/SimplePermissionManager.png -------------------------------------------------------------------------------- /src/icon/flaticon-approved-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPEnology-Community/SimplePermissionManager/HEAD/src/icon/flaticon-approved-512.png -------------------------------------------------------------------------------- /docs/images/spm-installation-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPEnology-Community/SimplePermissionManager/HEAD/docs/images/spm-installation-01.png -------------------------------------------------------------------------------- /docs/images/spm-installation-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPEnology-Community/SimplePermissionManager/HEAD/docs/images/spm-installation-02.png -------------------------------------------------------------------------------- /docs/images/spm-installation-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPEnology-Community/SimplePermissionManager/HEAD/docs/images/spm-installation-03.png -------------------------------------------------------------------------------- /docs/images/spm-installation-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPEnology-Community/SimplePermissionManager/HEAD/docs/images/spm-installation-04.png -------------------------------------------------------------------------------- /docs/images/spm-installation-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPEnology-Community/SimplePermissionManager/HEAD/docs/images/spm-installation-05.png -------------------------------------------------------------------------------- /docs/images/spm-installation-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPEnology-Community/SimplePermissionManager/HEAD/docs/images/spm-installation-06.png -------------------------------------------------------------------------------- /src/app/helptoc.conf: -------------------------------------------------------------------------------- 1 | { 2 | "app": "SynoCommunity.SimplePermissionManager.AppInstance", 3 | "title": "app:index_title", 4 | "content": "SimplePermissionManager_index.html", 5 | "toc": [] 6 | } 7 | -------------------------------------------------------------------------------- /src/bin/spm-update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -f /usr/local/bin/spm-exec 4 | 5 | cp /var/packages/SimplePermissionManager/target/bin/spm-exec /usr/local/bin/spm-exec 6 | 7 | chown root:root /usr/local/bin/spm-exec 8 | chmod 6755 /usr/local/bin/spm-exec -------------------------------------------------------------------------------- /src/app/texts/chs/strings: -------------------------------------------------------------------------------- 1 | [app] 2 | app_name = "权限管理器" 3 | description = "权限管理器" 4 | index_title = "权限管理器" 5 | 6 | [ui] 7 | overview = "概览" 8 | configure = "配置" 9 | permission = "权限" 10 | package = "套件" 11 | packages = "套件" 12 | user = "用户" 13 | users = "用户" 14 | audit_logs = "审计日志" 15 | active = "激活" 16 | status = "状态" 17 | status_unknown = "未知状态" 18 | status_active = "已激活" 19 | status_inactive = "未激活" 20 | trust_signature = "信任签名" -------------------------------------------------------------------------------- /src/wizard/install_uifile_chs: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "step_title": "套件信息", 4 | "items": [ 5 | { 6 | "desc": "权限管理器用于自动批准其他套件的特权命令, 一些驱动套件需要特权命令才可正常执行.

想了解更多信息,可以访问 权限管理器 Github 网页.

此套件的 Approved icons 由 Freepik - Flaticon 创建" 7 | } 8 | ] 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /src/cmd/audit/db.go: -------------------------------------------------------------------------------- 1 | package audit 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/glebarez/sqlite" 7 | "gorm.io/gorm" 8 | ) 9 | 10 | var ( 11 | db *gorm.DB 12 | dsn = "/var/packages/SimplePermissionManager/var/audit.db" 13 | ) 14 | 15 | func init() { 16 | var err error 17 | db, err = gorm.Open(sqlite.Open(dsn), &gorm.Config{}) 18 | if err != nil { 19 | panic(fmt.Sprintf("failed to connect audit database, dsn: %s", dsn)) 20 | } 21 | 22 | db.AutoMigrate(&Audit{}) 23 | } 24 | -------------------------------------------------------------------------------- /src/app/texts/enu/strings: -------------------------------------------------------------------------------- 1 | [app] 2 | app_name = "Simple Permission Manager" 3 | description = "Simple Permission Manager" 4 | index_title = "SimplePermissionManager" 5 | 6 | [ui] 7 | overview = "Overview" 8 | configure = "Configure" 9 | permission = "Permission" 10 | package = "Package" 11 | packages = "Packages" 12 | user = "User" 13 | users = "Users" 14 | audit_logs = "Audit Logs" 15 | active = "Active" 16 | status = "Status" 17 | status_unknown = "Unknown" 18 | status_active = "Active" 19 | status_inactive = "Inactive" 20 | trust_signature = "Trust Signature" -------------------------------------------------------------------------------- /src/cmd/audit/reason.go: -------------------------------------------------------------------------------- 1 | package audit 2 | 3 | import "fmt" 4 | 5 | func ReasonPackageValid(uid int, pkg string) string { 6 | return fmt.Sprintf("package %s is valid for user %d", pkg, uid) 7 | } 8 | 9 | func ReasonUserVaild(uid int) string { 10 | return fmt.Sprintf("user %d is valid", uid) 11 | } 12 | 13 | func ReasonSignatureVaild(signer string) string { 14 | return fmt.Sprintf("signature signer %s is valid", signer) 15 | } 16 | 17 | func ReasonInvaild(uid int) string { 18 | return fmt.Sprintf("user %d is not in approved user and package list and command did not have signature", uid) 19 | } 20 | -------------------------------------------------------------------------------- /src/wizard/install_uifile: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "step_title": "Information", 4 | "items": [ 5 | { 6 | "desc": "Simple Permission Manager is used to approve priviledged commands automatically, some drivers packages and other packages need high permission to execute their actions.

For more information, you can visit the Simple Permission Manager Github page.

Package's Approved icons created by Freepik - Flaticon" 7 | } 8 | ] 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /src/app/help/enu/SimplePermissionManager_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | This is the english help for SimpleExtJSApp
13 | 14 | 15 | -------------------------------------------------------------------------------- /src/service-setup.sh: -------------------------------------------------------------------------------- 1 | 2 | service_postinst () 3 | { 4 | # https://help.synology.com/developer-guide/synology_package/script_env_var.html 5 | 6 | for file in config.json permissions.json; do 7 | if [ ! -e /var/packages/SimplePermissionManager/etc/${file} ]; then 8 | cp -f ${SYNOPKG_PKGDEST}/etc.defaults/${file} /var/packages/SimplePermissionManager/etc/${file} 9 | fi 10 | done 11 | 12 | ${SYNOPKG_PKGDEST}/bin/init-permision.py 13 | 14 | if [ -e /usr/local/bin/spm-exec ]; then 15 | st=$(stat -c "%U %G %a" /usr/local/bin/spm-exec) 16 | if [ "$st" = "root root 6755" ]; then 17 | /usr/local/bin/spm-exec ${SYNOPKG_PKGDEST}/bin/spm-update 18 | fi 19 | fi 20 | } 21 | -------------------------------------------------------------------------------- /src/cgi/config.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import json 4 | import os 5 | import stat 6 | 7 | from pathlib import Path 8 | 9 | config_file = "/var/packages/SimplePermissionManager/etc/config.json" 10 | 11 | if __name__ == '__main__': 12 | print("Content-type: application/json\n") 13 | f = os.popen('/usr/syno/synoman/webman/modules/authenticate.cgi','r') 14 | user = f.read() 15 | 16 | # check user is authenticated 17 | if len(user) > 0: 18 | config = {} 19 | 20 | if os.path.exists(config_file): 21 | with open(config_file) as file: 22 | config = json.load(file) 23 | 24 | print(json.dumps(config, indent=4)) 25 | # reject in case of no authentication 26 | else: 27 | print ("Security : no user authenticated") 28 | -------------------------------------------------------------------------------- /src/app/config: -------------------------------------------------------------------------------- 1 | { 2 | "SimplePermissionManager.js": { 3 | "SynoCommunity.SimplePermissionManager.AppInstance": { 4 | "type": "app", 5 | "title": "app:app_name", 6 | "version": "0.2", 7 | "icon": "images/SimplePermissionManager-{0}.png", 8 | "texts": "texts", 9 | "allowMultiInstance": false, 10 | "allUsers": false, 11 | "appWindow": "SynoCommunity.SimplePermissionManager.AppWindow", 12 | "depend": ["SynoCommunity.SimplePermissionManager.AppWindow"] 13 | }, 14 | "SynoCommunity.SimplePermissionManager.AppWindow": { 15 | "type": "lib", 16 | "title": "app:app_name", 17 | "icon": "images/SimplePermissionManager-{0}.png", 18 | "texts": "texts" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/conf/resource: -------------------------------------------------------------------------------- 1 | { 2 | "usr-local-linker": { 3 | "bin": [ 4 | "bin/spm-update" 5 | ] 6 | }, 7 | "webservice": { 8 | "services": [ 9 | { 10 | "service": "SimplePermissionManager", 11 | "display_name": "Simple Permission Manager", 12 | "type": "static", 13 | "root": "SimplePermissionManager", 14 | "icon": "app/images/SimplePermissionManager-{0}.png" 15 | } 16 | ], 17 | "migrate": { 18 | "root": [ 19 | { 20 | "old": "sc-SimplePermissionManager", 21 | "new": "sc-SimplePermissionManager" 22 | } 23 | ] 24 | }, 25 | "pkg_dir_prepare": [ 26 | { 27 | "source": "/var/packages/SimplePermissionManager/target/app", 28 | "target": "SimplePermissionManager", 29 | "mode": "0755", 30 | "group": "http", 31 | "user": "sc-SimplePermissionManager" 32 | } 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/bin/init-permision.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import json 4 | import os 5 | import pwd 6 | import sys 7 | 8 | permissions_file = '/var/packages/SimplePermissionManager/etc/permissions.json' 9 | 10 | def get_package(package): 11 | pwall = pwd.getpwall() 12 | 13 | # for packages which not in /etc/passwd, default user is root 14 | name = 'root' 15 | uid = 0 16 | gid = 0 17 | 18 | for user in pwall: 19 | if user.pw_dir == '/var/packages/%s/home' % package: 20 | name = user.pw_name 21 | uid = user.pw_uid 22 | gid = user.pw_gid 23 | 24 | return {'name': name, 'uid': uid, 'gid': gid, 'package': package} 25 | 26 | def update_package(package): 27 | permissions = {'users':{},'packages':{}} 28 | 29 | if os.path.exists(permissions_file): 30 | with open(permissions_file) as file: 31 | permissions = json.load(file) 32 | 33 | permissions['packages'][package['package']] = package 34 | 35 | file = open(permissions_file, 'w') 36 | file.write(json.dumps(permissions, indent=4)) 37 | file.close() 38 | 39 | if __name__ == '__main__': 40 | package = get_package("SimplePermissionManager") 41 | package['enabled'] = True 42 | update_package(package) -------------------------------------------------------------------------------- /src/cmd/go.mod: -------------------------------------------------------------------------------- 1 | module spm 2 | 3 | go 1.21.3 4 | 5 | require github.com/stretchr/testify v1.8.4 6 | 7 | require ( 8 | github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect 9 | github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f // indirect 10 | github.com/ProtonMail/gopenpgp/v2 v2.7.5 // indirect 11 | github.com/cloudflare/circl v1.3.3 // indirect 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/dustin/go-humanize v1.0.1 // indirect 14 | github.com/glebarez/go-sqlite v1.21.2 // indirect 15 | github.com/glebarez/sqlite v1.11.0 // indirect 16 | github.com/google/uuid v1.3.0 // indirect 17 | github.com/jinzhu/inflection v1.0.0 // indirect 18 | github.com/jinzhu/now v1.1.5 // indirect 19 | github.com/mattn/go-isatty v0.0.17 // indirect 20 | github.com/pkg/errors v0.9.1 // indirect 21 | github.com/pmezard/go-difflib v1.0.0 // indirect 22 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect 23 | golang.org/x/crypto v0.7.0 // indirect 24 | golang.org/x/sys v0.7.0 // indirect 25 | golang.org/x/text v0.8.0 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | gorm.io/gorm v1.25.7 // indirect 28 | modernc.org/libc v1.22.5 // indirect 29 | modernc.org/mathutil v1.5.0 // indirect 30 | modernc.org/memory v1.5.0 // indirect 31 | modernc.org/sqlite v1.23.1 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /src/cgi/list-audit-logs.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import io 4 | import os 5 | import json 6 | import sqlite3 7 | 8 | from urllib.parse import parse_qs 9 | 10 | audit_db_file = '/var/packages/SimplePermissionManager/var/audit.db' 11 | 12 | def print_audit_logs(): 13 | offset = 0 14 | limit = 100 15 | 16 | if "QUERY_STRING" in os.environ: 17 | query = os.environ['QUERY_STRING'] 18 | pairs = parse_qs(query) 19 | if 'offset' in pairs: 20 | offset = int(pairs['offset'][0]) 21 | if 'limit' in pairs: 22 | limit = int(pairs['limit'][0]) 23 | 24 | conn = sqlite3.connect(audit_db_file) 25 | conn.row_factory = sqlite3.Row 26 | db = conn.cursor() 27 | 28 | rows = db.execute('SELECT * FROM audits ORDER BY id DESC LIMIT ? OFFSET ?', (limit, offset)).fetchall() 29 | total = db.execute("SELECT COUNT(*) FROM audits").fetchone()[0] 30 | 31 | conn.commit() 32 | conn.close() 33 | 34 | output = { 35 | 'result': [dict(ix) for ix in rows], 36 | 'success': True, 37 | 'total': total 38 | } 39 | print(json.dumps(output, indent=4)) 40 | 41 | if __name__ == '__main__': 42 | print("Content-type: application/json\n") 43 | f = os.popen('/usr/syno/synoman/webman/modules/authenticate.cgi','r') 44 | user = f.read() 45 | 46 | # check user is authenticated 47 | if len(user)>0: 48 | print_audit_logs() 49 | # reject in case of no authentication 50 | else: 51 | print ("Security : no user authenticated") 52 | -------------------------------------------------------------------------------- /src/cmd/parse_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestParseArgs(t *testing.T) { 10 | var testCases = []struct { 11 | name string 12 | args []string 13 | spmArgs []string 14 | commandAndArgs []string 15 | }{ 16 | { 17 | name: "simple", 18 | args: []string{"ls"}, 19 | spmArgs: nil, 20 | commandAndArgs: []string{"ls"}, 21 | }, 22 | { 23 | name: "help", 24 | args: []string{"-h"}, 25 | spmArgs: []string{"-h"}, 26 | commandAndArgs: nil, 27 | }, 28 | { 29 | name: "pid", 30 | args: []string{"-pid", "/var/run/pid", "ls"}, 31 | spmArgs: []string{"-pid", "/var/run/pid"}, 32 | commandAndArgs: []string{"ls"}, 33 | }, 34 | { 35 | name: "pid with double dash", 36 | args: []string{"-pid", "/var/run/pid", "--", "ls"}, 37 | spmArgs: []string{"-pid", "/var/run/pid"}, 38 | commandAndArgs: []string{"ls"}, 39 | }, 40 | { 41 | name: "pid with double dash * 2", 42 | args: []string{"-pid", "/var/run/pid", "--", "--"}, 43 | spmArgs: []string{"-pid", "/var/run/pid"}, 44 | commandAndArgs: []string{"--"}, 45 | }, 46 | } 47 | 48 | for _, tc := range testCases { 49 | t.Run(tc.name, func(t *testing.T) { 50 | spmArgs, commandAndArgs := parseArgs(tc.args) 51 | assert.Equal(t, spmArgs, tc.spmArgs) 52 | assert.Equal(t, commandAndArgs, tc.commandAndArgs) 53 | }) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/cmd/audit/audit.go: -------------------------------------------------------------------------------- 1 | package audit 2 | 3 | import ( 4 | "gorm.io/gorm" 5 | ) 6 | 7 | type Action int 8 | type Type int 9 | 10 | var ( 11 | ActionApproved = Action(0) 12 | ActionDenied = Action(1) 13 | 14 | TypeUser = Type(0) 15 | TypePackage = Type(1) 16 | TypeSignature = Type(2) 17 | ) 18 | 19 | type Audit struct { 20 | gorm.Model 21 | 22 | Command string 23 | UID int 24 | Package string 25 | SignatureSigner string 26 | Type int 27 | Action int 28 | Reason string 29 | } 30 | 31 | func Add(cmd string, uid int, action Action, pkg string, signer string, typ Type, reason string) error { 32 | result := db.Create(&Audit{ 33 | Command: cmd, 34 | UID: uid, 35 | Package: pkg, 36 | SignatureSigner: signer, 37 | Type: int(typ), 38 | Action: int(action), 39 | Reason: reason, 40 | }) 41 | return result.Error 42 | } 43 | 44 | func AddPackageApproved(cmd string, uid int, pkg string) error { 45 | return Add(cmd, uid, ActionApproved, pkg, "", TypePackage, ReasonPackageValid(uid, pkg)) 46 | } 47 | 48 | func AddUserApproved(cmd string, uid int) error { 49 | return Add(cmd, uid, ActionApproved, "", "", TypeUser, ReasonUserVaild(uid)) 50 | } 51 | 52 | func AddSignatureApproved(cmd string, uid int, signer string) error { 53 | return Add(cmd, uid, ActionApproved, "", signer, TypeSignature, ReasonSignatureVaild(signer)) 54 | } 55 | 56 | func AddDenied(cmd string, uid int) error { 57 | return Add(cmd, uid, ActionDenied, "", "", TypeUser, ReasonInvaild(uid)) 58 | } 59 | -------------------------------------------------------------------------------- /src/cgi/update-user.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import json 4 | import os 5 | import pwd 6 | import sys 7 | 8 | permissions_file = '/var/packages/SimplePermissionManager/etc/permissions.json' 9 | 10 | def get_user(user_name): 11 | pwall = pwd.getpwall() 12 | 13 | name = 'root' 14 | uid = 0 15 | gid = 0 16 | 17 | for user in pwall: 18 | if user.pw_name == user_name: 19 | name = user.pw_name 20 | uid = user.pw_uid 21 | gid = user.pw_gid 22 | 23 | return {'name': name, 'uid': uid, 'gid': gid} 24 | 25 | def update_user(user): 26 | permissions = {'users':{},'packages':{}} 27 | 28 | if os.path.exists(permissions_file): 29 | with open(permissions_file) as file: 30 | permissions = json.load(file) 31 | 32 | permissions['users'][user['name']] = user 33 | 34 | file = open(permissions_file, 'w') 35 | file.write(json.dumps(permissions, indent=4)) 36 | file.close() 37 | 38 | def process(): 39 | content_len = int(os.environ.get('CONTENT_LENGTH', 0)) 40 | # method = os.environ.get('REQUEST_METHOD', '') 41 | # query_string = os.environ.get('QUERY_STRING', '') 42 | # x_header = os.environ.get('HTTP_X_MARVIN_STATUS', '') 43 | body = sys.stdin.read(content_len) 44 | request = json.loads(body) 45 | 46 | user = get_user(request['name']) 47 | user['enabled'] = request['enabled'] 48 | 49 | update_user(user) 50 | 51 | if __name__ == '__main__': 52 | print("Content-type: application/json\n") 53 | f = os.popen('/usr/syno/synoman/webman/modules/authenticate.cgi','r') 54 | user = f.read() 55 | 56 | # check user is authenticated 57 | if len(user)>0: 58 | process() 59 | # reject in case of no authentication 60 | else: 61 | print("Security : no user authenticated") -------------------------------------------------------------------------------- /src/cgi/update-package.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import json 4 | import os 5 | import pwd 6 | import sys 7 | 8 | permissions_file = '/var/packages/SimplePermissionManager/etc/permissions.json' 9 | 10 | def get_package(package): 11 | pwall = pwd.getpwall() 12 | 13 | # for packages which not in /etc/passwd, default user is root 14 | name = 'root' 15 | uid = 0 16 | gid = 0 17 | 18 | for user in pwall: 19 | if user.pw_dir == '/var/packages/%s/home' % package: 20 | name = user.pw_name 21 | uid = user.pw_uid 22 | gid = user.pw_gid 23 | 24 | return {'name': name, 'uid': uid, 'gid': gid, 'package': package} 25 | 26 | def update_package(package): 27 | permissions = {'users':{},'packages':{}} 28 | 29 | if os.path.exists(permissions_file): 30 | with open(permissions_file) as file: 31 | permissions = json.load(file) 32 | 33 | permissions['packages'][package['package']] = package 34 | 35 | file = open(permissions_file, 'w') 36 | file.write(json.dumps(permissions, indent=4)) 37 | file.close() 38 | 39 | def process(): 40 | content_len = int(os.environ.get('CONTENT_LENGTH', 0)) 41 | # method = os.environ.get('REQUEST_METHOD', '') 42 | # query_string = os.environ.get('QUERY_STRING', '') 43 | # x_header = os.environ.get('HTTP_X_MARVIN_STATUS', '') 44 | body = sys.stdin.read(content_len) 45 | request = json.loads(body) 46 | 47 | package = get_package(request['package']) 48 | package['enabled'] = request['enabled'] 49 | 50 | update_package(package) 51 | 52 | if __name__ == '__main__': 53 | print("Content-type: application/json\n") 54 | f = os.popen('/usr/syno/synoman/webman/modules/authenticate.cgi','r') 55 | user = f.read() 56 | 57 | # check user is authenticated 58 | if len(user)>0: 59 | process() 60 | # reject in case of no authentication 61 | else: 62 | print("Security : no user authenticated") -------------------------------------------------------------------------------- /src/cgi/list-users.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import json 4 | import os 5 | import pwd 6 | 7 | from urllib.parse import parse_qs 8 | 9 | permissions_file = '/var/packages/SimplePermissionManager/etc/permissions.json' 10 | 11 | def list_users(): 12 | permissions = {} 13 | 14 | if os.path.exists(permissions_file): 15 | with open(permissions_file) as file: 16 | permissions = json.load(file) 17 | 18 | pwall = pwd.getpwall() 19 | users = [] 20 | for user in pwall: 21 | enabled = False 22 | if 'users' in permissions and user.pw_name in permissions["users"] and 'enabled' in permissions["users"][user.pw_name]: 23 | enabled = permissions["users"][user.pw_name]['enabled'] 24 | 25 | users.append({'name': user.pw_name, 'uid': user.pw_uid, 'gid': user.pw_gid, 'enabled': enabled}) 26 | 27 | users = sorted(users, key=lambda x: x['uid']) 28 | for i in range(len(users)): 29 | users[i]['id'] = i+1 30 | 31 | return users 32 | 33 | def print_users(): 34 | offset = 0 35 | limit = -1 36 | 37 | if "QUERY_STRING" in os.environ: 38 | query = os.environ['QUERY_STRING'] 39 | pairs = parse_qs(query) 40 | if 'offset' in pairs: 41 | offset = int(pairs['offset'][0]) 42 | if 'limit' in pairs: 43 | limit = int(pairs['limit'][0]) 44 | 45 | all_users = list_users() 46 | users = [] 47 | 48 | if limit == -1: 49 | users = all_users 50 | else: 51 | users = all_users[offset:offset+limit] 52 | 53 | output = { 54 | 'result': users, 55 | 'success': True, 56 | 'total': len(all_users) 57 | } 58 | print(json.dumps(output, indent=4)) 59 | 60 | if __name__ == '__main__': 61 | print("Content-type: application/json\n") 62 | f = os.popen('/usr/syno/synoman/webman/modules/authenticate.cgi','r') 63 | user = f.read() 64 | 65 | # check user is authenticated 66 | if len(user)>0: 67 | print_users() 68 | # reject in case of no authentication 69 | else: 70 | print ("Security : no user authenticated") 71 | -------------------------------------------------------------------------------- /src/cgi/status.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import json 4 | import os 5 | import stat 6 | import io 7 | import configparser 8 | import subprocess 9 | 10 | from pathlib import Path 11 | 12 | exec_path = "/usr/local/bin/spm-exec" 13 | 14 | if __name__ == '__main__': 15 | print("Content-type: application/json\n") 16 | f = os.popen('/usr/syno/synoman/webman/modules/authenticate.cgi','r') 17 | user = f.read() 18 | 19 | # check user is authenticated 20 | if len(user) > 0: 21 | acvite = True 22 | 23 | if not os.path.exists(exec_path): 24 | acvite = False 25 | else: 26 | file_owner = Path(exec_path).owner() 27 | file_stat = os.stat(exec_path) 28 | 29 | # 1. check owner 30 | if file_owner != 'root': 31 | acvite = False 32 | 33 | # 2. check mode 34 | file_mode = stat.S_IMODE(file_stat.st_mode) 35 | if not (stat.S_ISUID & file_mode): 36 | acvite = False 37 | 38 | if not (stat.S_IRWXU & file_mode): 39 | acvite = False 40 | 41 | # 3. check verify output 42 | if acvite is True: 43 | desire = "Simple Permission Manager is awesome" 44 | real = subprocess.run(["/usr/local/bin/spm-exec", "echo", desire], stdout=subprocess.PIPE, check=False).stdout.decode() 45 | if desire not in real: 46 | acvite = False 47 | 48 | version_path = '/etc/VERSION' 49 | version_str = '[root]\n' + open(version_path, 'r').read() 50 | fp = io.StringIO(version_str) 51 | config = configparser.RawConfigParser() 52 | config.read_file(fp) 53 | 54 | major = config['root']['major'].strip('"') 55 | minor = config['root']['minor'].strip('"') 56 | base = config['root']['base'].strip('"') 57 | 58 | print(json.dumps( 59 | { 60 | 'active': acvite, 61 | 'major': major, 62 | 'minor': minor, 63 | 'base': base, 64 | }, indent=4)) 65 | # reject in case of no authentication 66 | else: 67 | print ("Security : no user authenticated") 68 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | target: 11 | - "x64-7.0" 12 | - "x64-7.2" 13 | - "aarch64-7.0" 14 | - "aarch64-7.2" 15 | include: 16 | - target: x64-7.0 17 | dsm_ver: 7.0 18 | go_arch: amd64 19 | - target: x64-7.2 20 | dsm_ver: 7.2 21 | go_arch: amd64 22 | - target: aarch64-7.0 23 | dsm_ver: 7.0 24 | go_arch: arm64 25 | - target: aarch64-7.2 26 | dsm_ver: 7.2 27 | go_arch: arm64 28 | steps: 29 | - uses: actions/checkout@v4 30 | - name: Setup Go 31 | uses: actions/setup-go@v4 32 | with: 33 | go-version: 1.22 34 | - name: Checkout SynoCommunity Source and Docker Image 35 | run: | 36 | git clone https://github.com/SynoCommunity/spksrc.git /home/runner/work/spksrc 37 | docker pull ghcr.io/synocommunity/spksrc 38 | - name: Install UPX 39 | uses: crazy-max/ghaction-upx@v3 40 | with: 41 | install-only: true 42 | - name: Restore cached Primes 43 | id: cache-primes-restore 44 | uses: actions/cache/restore@v4 45 | with: 46 | path: | 47 | /home/runner/work/spksrc/distrib 48 | ~/.cache/go-build 49 | ~/go/pkg/mod 50 | key: ${{ runner.os }}-spksrc-primes-${{ matrix.target }} 51 | - name: Build Binary 52 | run: | 53 | workdir=$(pwd) 54 | export CGO_ENABLED=0 55 | export GOARCH=${{ matrix.go_arch }} 56 | (cd $workdir/src/cmd && go build -ldflags="-s -w" -o ../bin/spm-exec spm-exec.go) 57 | upx -9 $workdir/src/bin/spm-exec 58 | - name: Build Package 59 | run: | 60 | workdir=$(pwd) 61 | docker run -v /home/runner/work/spksrc:/spksrc \ 62 | -v $workdir:/spksrc/spk/simplepermissionmanager \ 63 | -v $workdir/packages:/spksrc/packages \ 64 | -w /spksrc/spk/simplepermissionmanager \ 65 | ghcr.io/synocommunity/spksrc \ 66 | make arch-${{ matrix.target }} 67 | - name: Release 68 | uses: softprops/action-gh-release@v1 69 | if: startsWith(github.ref, 'refs/tags/') 70 | with: 71 | files: packages/*.spk 72 | - name: Save Primes 73 | id: cache-primes-save 74 | uses: actions/cache/save@v4 75 | with: 76 | path: | 77 | /home/runner/work/spksrc/distrib 78 | key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }} 79 | -------------------------------------------------------------------------------- /src/cgi/list-packages.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import io 4 | import json 5 | import os 6 | import configparser 7 | 8 | from urllib.parse import parse_qs 9 | 10 | permissions_file = '/var/packages/SimplePermissionManager/etc/permissions.json' 11 | 12 | def chunks(lst, n): 13 | """Yield successive n-sized chunks from lst.""" 14 | for i in range(0, len(lst), n): 15 | yield lst[i:i + n] 16 | 17 | def list_packages(): 18 | packages = [] 19 | permissions = {} 20 | 21 | if os.path.exists(permissions_file): 22 | with open(permissions_file) as file: 23 | permissions = json.load(file) 24 | 25 | directories = [d for d in os.listdir('/var/packages') if os.path.isdir('/var/packages/'+d)] 26 | for dir in directories: 27 | package = '' 28 | version = '' 29 | description = '' 30 | 31 | ini_path = '/var/packages/%s/INFO' % dir 32 | ini_str = '[root]\n' + open(ini_path, 'r').read() 33 | ini_fp = io.StringIO(ini_str) 34 | config = configparser.RawConfigParser() 35 | config.read_file(ini_fp) 36 | 37 | package = config['root']['package'].strip('"') 38 | version = config['root']['version'].strip('"') 39 | if 'description' in config['root']: 40 | description = config['root']['description'].strip('"') 41 | 42 | enabled = False 43 | if 'packages' in permissions and package in permissions["packages"] and 'enabled' in permissions["packages"][package]: 44 | enabled = permissions["packages"][package]['enabled'] 45 | 46 | if package != "SimplePermissionManager": 47 | packages.append({ 48 | 'package': package, 49 | 'version': version, 50 | 'enabled': enabled, 51 | 'description': description 52 | }) 53 | 54 | packages = sorted(packages, key=lambda x: x['package']) 55 | for i in range(len(packages)): 56 | packages[i]['id'] = i+1 57 | 58 | return packages 59 | 60 | def print_packages(): 61 | offset = 0 62 | limit = -1 63 | 64 | if "QUERY_STRING" in os.environ: 65 | query = os.environ['QUERY_STRING'] 66 | pairs = parse_qs(query) 67 | if 'offset' in pairs: 68 | offset = int(pairs['offset'][0]) 69 | if 'limit' in pairs: 70 | limit = int(pairs['limit'][0]) 71 | 72 | all_packages = list_packages() 73 | packages = [] 74 | 75 | if limit == -1: 76 | packages = all_packages 77 | else: 78 | packages = all_packages[offset:offset+limit] 79 | 80 | output = { 81 | 'result': packages, 82 | 'success': True, 83 | 'total': len(all_packages) 84 | } 85 | print(json.dumps(output, indent=4)) 86 | 87 | if __name__ == '__main__': 88 | print("Content-type: application/json\n") 89 | f = os.popen('/usr/syno/synoman/webman/modules/authenticate.cgi','r') 90 | user = f.read() 91 | 92 | # check user is authenticated 93 | if len(user)>0: 94 | print_packages() 95 | # reject in case of no authentication 96 | else: 97 | print ("Security : no user authenticated") 98 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SPK_NAME = SimplePermissionManager 2 | SPK_VERS = 1.0.0 3 | SPK_REV = 10 4 | SPK_ICON = src/SimplePermissionManager.png 5 | WIZARDS_DIR = src/wizard 6 | DSM_UI_DIR = app 7 | DSM_APP_NAME = SynoCommunity.SimplePermissionManager.AppInstance 8 | # workaround for creating package icons, while ADMIN_URL and SERVICE_PORT is none 9 | DSM_UI_CONFIG = src/app/config 10 | 11 | MAINTAINER = jim3ma 12 | 13 | DESCRIPTION = Simple Permission Manager is used to approve some packages' priviledged commands automatically, some drivers packages and other packages need high permission to execute their actions. 14 | DESCRIPTION_CHS = 权限管理器用于自动批准其他套件的特权命令, 一些驱动套件需要特权命令才可正常执行. 15 | 16 | DISPLAY_NAME = Simple Permission Manager 17 | DISPLAY_NAME_CHS = 权限管理器 18 | 19 | STARTABLE = no 20 | 21 | HOMEPAGE = https://github.com/XPEnology-Community/SimplePermissionManager 22 | 23 | CONF_DIR = src/conf 24 | SYSTEM_GROUP = http 25 | 26 | SERVICE_USER = auto 27 | SERVICE_SETUP = src/service-setup.sh 28 | 29 | COPY_TARGET = nop 30 | 31 | POST_STRIP_TARGET = SimplePermissionManager_extra_install 32 | 33 | include ../../mk/spksrc.spk.mk 34 | 35 | .PHONY: SimplePermissionManager_extra_install 36 | SimplePermissionManager_extra_install: 37 | install -m 755 -d $(STAGING_DIR)/app/ 38 | 39 | ln -s /var/packages/SimplePermissionManager/target/cgi/ $(STAGING_DIR)/app/cgi 40 | install -m 644 src/app/SimplePermissionManager.js $(STAGING_DIR)/app/SimplePermissionManager.js 41 | install -m 644 src/app/config $(STAGING_DIR)/app/config 42 | install -m 644 src/app/helptoc.conf $(STAGING_DIR)/app/helptoc.conf 43 | 44 | install -m 755 -d $(STAGING_DIR)/app/help 45 | for language in enu; do \ 46 | install -m 755 -d $(STAGING_DIR)/app/help/$${language}; \ 47 | install -m 644 src/app/help/$${language}/SimplePermissionManager_index.html $(STAGING_DIR)/app/help/$${language}/SimplePermissionManager_index.html; \ 48 | done 49 | install -m 755 -d $(STAGING_DIR)/app/texts 50 | for language in chs enu; do \ 51 | install -m 755 -d $(STAGING_DIR)/app/texts/$${language}; \ 52 | install -m 644 src/app/texts/$${language}/strings $(STAGING_DIR)/app/texts/$${language}/strings; \ 53 | done 54 | 55 | install -m 755 -d $(STAGING_DIR)/cgi/ 56 | install -m 755 src/cgi/config.cgi $(STAGING_DIR)/cgi/config.cgi 57 | install -m 755 src/cgi/list-audit-logs.cgi $(STAGING_DIR)/cgi/list-audit-logs.cgi 58 | install -m 755 src/cgi/list-packages.cgi $(STAGING_DIR)/cgi/list-packages.cgi 59 | install -m 755 src/cgi/list-users.cgi $(STAGING_DIR)/cgi/list-users.cgi 60 | install -m 755 src/cgi/status.cgi $(STAGING_DIR)/cgi/status.cgi 61 | install -m 755 src/cgi/update-package.cgi $(STAGING_DIR)/cgi/update-package.cgi 62 | install -m 755 src/cgi/update-user.cgi $(STAGING_DIR)/cgi/update-user.cgi 63 | 64 | install -m 755 -d $(STAGING_DIR)/bin/ 65 | install -m 755 src/bin/init-permision.py $(STAGING_DIR)/bin/init-permision.py 66 | install -m 755 src/bin/spm-exec $(STAGING_DIR)/bin/spm-exec 67 | install -m 755 src/bin/spm-update $(STAGING_DIR)/bin/spm-update 68 | install -m 644 src/bin/spm-update.sig $(STAGING_DIR)/bin/spm-update.sig 69 | 70 | install -m 755 -d $(STAGING_DIR)/etc.defaults/ 71 | install -m 644 src/etc.defaults/config.json $(STAGING_DIR)/etc.defaults/config.json 72 | install -m 644 src/etc.defaults/permissions.json $(STAGING_DIR)/etc.defaults/permissions.json 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple Permission Manager 2 | 3 | `Simple Permission Manager` is used to approve some packages' priviledged commands automatically, some drivers packages and other packages need high permission to execute their actions. 4 | 5 | ## User Guide 6 | 7 | ### Installation 8 | 9 | 1. Download package from https://github.com/XPEnology-Community/SimplePermissionManager/releases 10 | 11 | 2. Install `Simple Permission Manager` in `Package Center` 12 | 13 | ![step 1](docs/images/spm-installation-01.png) 14 | 15 | 3. Open `Simple Permission Manager` 16 | 17 | * From `Package Center` 18 | 19 | ![step 2](docs/images/spm-installation-02.png) 20 | 21 | * From `Main Menu` 22 | 23 | ![step 3](docs/images/spm-installation-03.png) 24 | 25 | 3. Click `Active` button 26 | 27 | ![step 4](docs/images/spm-installation-04.png) 28 | 29 | 4. Type password 30 | 31 | ![step 5](docs/images/spm-installation-05.png) 32 | 33 | 5. Actived 34 | 35 | ![step 6](docs/images/spm-installation-06.png) 36 | 37 | ### Manually Approve Package Guide 38 | 39 | 1. Open `Simple Permission Manager` in DSM 40 | 2. Click `Package` in tab 41 | 3. Enable target package by clicking checkbox 42 | 43 | ### Manually Approve User Guide 44 | 45 | 1. Open `Simple Permission Manager` in DSM 46 | 2. Click `User` in tab 47 | 3. Enable target user by clicking checkbox 48 | 49 | ## Devloper Guide 50 | 51 | ### Auto Approve Guide 52 | 53 | #### Generate Middle Public Key Signature 54 | 55 | > Prepare gpg key before the following steps 56 | 57 | 1. Export middle public key 58 | 59 | ```shell 60 | gpg --output public.pgp --export 'Hello World ' 61 | ``` 62 | 63 | 2. Send public key to Jim to sign by root key 64 | 65 | ```shell 66 | gpg --output public.pgp.sig --detach-sign public.pgp 67 | ``` 68 | 69 | 3. Save middle public key signature 70 | 71 | Save `public.pgp` and `public.pgp.sig` 72 | 73 | #### Generate Binary Signature 74 | 75 | 1. Sign by middle key 76 | 77 | ```shell 78 | gpg --output hello-world.sh.gpg.sig --detach-sign hello-world.sh 79 | ``` 80 | 81 | 2. Save binary signature 82 | 83 | File name: `hello-world.sh.sig` 84 | 85 | ```json 86 | { 87 | "version": 1, 88 | "signature": "", 89 | "publicKeys": [ 90 | { 91 | "publicKey": "", 92 | "signature": "" 93 | } 94 | ] 95 | } 96 | ``` 97 | 98 | ##### Sign Script 99 | 100 | ```shell 101 | file=hello-world.sh 102 | 103 | pub_key=$(base64 -w 0 public.pgp) 104 | pub_sig=$(base64 -w 0 public.pgp.sig) 105 | 106 | sha256=$(sha256sum $file | awk '{print $1}') 107 | gpg --output "$file".gpg.sig --detach-sign "$file" 108 | sig=$(base64 -w 0 "$file".gpg.sig) 109 | rm -f "$file".gpg.sig 110 | 111 | cat << EOF > "$file".sig 112 | { 113 | "version": 1, 114 | "sha256": "${sha256}", 115 | "signature": "${sig}", 116 | "publicKeys": [ 117 | { 118 | "publicKey": "${pub_key}", 119 | "signature": "${pub_sig}" 120 | } 121 | ] 122 | } 123 | EOF 124 | ``` 125 | 126 | ### Run Command in Packages 127 | 128 | ``` 129 | ## check permission first 130 | if [ ! -e /usr/local/bin/spm-exec ]; then 131 | echo "ERROR: /usr/local/bin/spm-exec not found. Please install SimplePermissionManager package and active it." 132 | exit 1 133 | fi 134 | 135 | st=$(stat -c "%U %G %a" /usr/local/bin/spm-exec) 136 | if [ ! "$st" = "root root 6755" ]; then 137 | echo "ERROR: /usr/local/bin/spm-exec permission is not ready. Please active SimplePermissionManager." 138 | exit 1 139 | fi 140 | 141 | ## 1. execute target command 142 | /usr/local/bin/spm-exec /path/to/hello-world.sh 143 | 144 | ## 2. execute target command and store pid 145 | ## if need check status with pid, please ensure parent script is root 146 | ## or also call spm-exec to check status, 147 | ## like: spm-exec kill -0 $pid, or proxy all script to spm-exec, eg: 148 | ## for start-stop-status, we can call spm-exec like this: 149 | ## start-stop-status -> spm-exec real-start-stop-status > real-start-stop-status 150 | /usr/local/bin/spm-exec -pid /path/to/pid /path/to/hello-world.sh 151 | ``` -------------------------------------------------------------------------------- /src/bin/spm-update.sig: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "sha256": "ae1fc45c8a547efafa9280f3ad039d11fe098261cd80ebcbf39d080d5550fd19", 4 | "signature": "iQIzBAABCgAdFiEEHFXk2Me3dpog+umeIPakP21pGPYFAmXYoRYACgkQIPakP21pGPZ/6g//Q2Rf3jyMQSZgeyZY17qHinmtQuwOjj7ABZ2yLM4tm5N/4tuTDfpIWTlI/RWhUioS+Rzz0cj/EdozJAApC0xnwCpHL5fU05+bvnYrMxK3/Me7nfmKaVdsNPMUemTQKXcFhAgPYdVSkwzQPbP2UGBIFb3tdhawNydY+wjphSiefy9f+AwWoEQgBjWjPbQPcN1TGO6dgHwT1x28O2t8yatZasgH6moKTO3/sVVxNVly+qknwtBui6oX8wYT6g/GKN9kApF5t+MNhv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ZSZZBwV4xt4mXmwjTKuzD1QLuxDbvSBm2gpMcYpBBsA4HfjPPia5Imr5YjssLJhP7PA5Zl7GNi7gEqzl2kHTne5m61jm2X3DpvNqNBjs9F7LAF04blTK58j1f410FDJ4h/tQbp9uEm6MfTKoxnzYd+Lf/UpIfKpHCdlh+yzcNXMXCI=", 8 | "signature": "iQIzBAABCgAdFiEEHFXk2Me3dpog+umeIPakP21pGPYFAmXYm4YACgkQIPakP21pGPYo3BAAqJJNyqfKLIVIHZYrUk0GMWXV+6HFcSfd8eEbkCcQEUr5hWStpL4RCi+CJY98MRd3HfsxY4o6h+Hj/Evt5aPiq3KtYF0EWGs3ahxIbyd/NPmVFvkpKKKNCjo6E9L/6OJbXfEF4hfTqLWbs8s9IGLCe6V0KrBsvDE1hF5m6hbA+lZfrN2uFrb7gNG4f5qBmZHvmK7iaTHrEujf4SRBgt0HXJ4UD8ACW6fRbQxRs7ctjvUuWcbCrz2O/h53uIeJ2R12oRNY28v/OxDQO8pGOga80CLnDCGcs/JJWgPaTgPXvWYHw230J+TIprjZ9fDwWjM+qAvwcFsvUVEPx3ywkF/wedg4WWHGQBHYGANI8zAjLmkvvThUdKRvwoXWQcZzanLKgcwGXSQ36tNq+bsxMqTwzfXFmmFkmMvLNZAm8hnzk9rq/OoSB4krtANeansIfOJN4kvhDLg26I/J5Lclf/ZhG2UF1HXOJatgEf8hLFgwnxb4FtoHIjsAB0pGMWCsD58SzNlDkZLVgGJno4Jz8zYEEwX9Ano4gqLfXTkhlK3HY8IxGorDiagmQH4pyUk5QF2ZZTJHiAL8sv1y1EGliHUCSwRcYD+0hypRfhhsikCtGU0j2a6XUNR1G5WqM4+Vwva9t/7e9G+JHmG/a88KHVMdTZmuvdzI+bStcw/qIu8l0mI=" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/cmd/go.sum: -------------------------------------------------------------------------------- 1 | github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= 2 | github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= 3 | github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f h1:tCbYj7/299ekTTXpdwKYF8eBlsYsDVoggDAuAjoK66k= 4 | github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f/go.mod h1:gcr0kNtGBqin9zDW9GOHcVntrwnjrK+qdJ06mWYBybw= 5 | github.com/ProtonMail/gopenpgp/v2 v2.7.5 h1:STOY3vgES59gNgoOt2w0nyHBjKViB/qSg7NjbQWPJkA= 6 | github.com/ProtonMail/gopenpgp/v2 v2.7.5/go.mod h1:IhkNEDaxec6NyzSI0PlxapinnwPVIESk8/76da3Ct3g= 7 | github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= 8 | github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= 9 | github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= 10 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 11 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 12 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 13 | github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= 14 | github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= 15 | github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo= 16 | github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k= 17 | github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw= 18 | github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ= 19 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 20 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 21 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 22 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 23 | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= 24 | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 25 | github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= 26 | github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= 27 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 28 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 29 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 30 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 31 | github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= 32 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= 33 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= 34 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 35 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 36 | github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= 37 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 38 | github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= 39 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 40 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 41 | golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= 42 | golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= 43 | golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= 44 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= 45 | golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= 46 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 47 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 48 | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 49 | golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= 50 | golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= 51 | golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= 52 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 53 | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 54 | golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 55 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 56 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 57 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 58 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 59 | golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 60 | golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 61 | golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 62 | golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 63 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 64 | golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= 65 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 66 | golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= 67 | golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 68 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 69 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 70 | golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= 71 | golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= 72 | golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= 73 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 74 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 75 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 76 | golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 77 | golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 78 | golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= 79 | golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= 80 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 81 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 82 | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= 83 | golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= 84 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 85 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 86 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 87 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 88 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 89 | gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A= 90 | gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= 91 | modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE= 92 | modernc.org/libc v1.22.5/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY= 93 | modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= 94 | modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= 95 | modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds= 96 | modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= 97 | modernc.org/sqlite v1.23.1 h1:nrSBg4aRQQwq59JpvGEQ15tNxoO5pX/kUjcRNwSAGQM= 98 | modernc.org/sqlite v1.23.1/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk= 99 | -------------------------------------------------------------------------------- /src/cmd/spm-exec.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/base64" 5 | "encoding/json" 6 | "flag" 7 | "fmt" 8 | "os" 9 | "os/exec" 10 | "os/user" 11 | "path" 12 | "spm/audit" 13 | "strconv" 14 | "strings" 15 | "syscall" 16 | 17 | "github.com/ProtonMail/gopenpgp/v2/crypto" 18 | ) 19 | 20 | var ( 21 | etcDir = "/var/packages/SimplePermissionManager/etc" 22 | 23 | permissionsPath = path.Join(etcDir, "permissions.json") 24 | configPath = path.Join(etcDir, "config.json") 25 | ) 26 | 27 | var rootPubKeys = []string{ 28 | `mQINBGXMuq8BEAC12lMEbGu7v4Agiju5LuacIyHTUKxEEdwybNX2Xyog67otSePnr1uC45yn2HST 29 | whKI34pDpv+74Myo6vIchH7kWB34xVwisEs5cGOzi48Nn7tjDxo7tI+CmA/KrsE04pouqttIqxmq 30 | fwnw3c6AEkykBiwXLBnc9AwSF50E8HjQ+fSAWj+tb1f+i2YoM1cpggEv3EQfXWsBOAay4A8CXZ2p 31 | txKCtiSnCzngLP5gw6na84q8vh7HdzwwoN4ehOO7vUyltO9KpMH/xAiXma3Sbx+nktrv0GDpo+1w 32 | uK85Vn2FmMAcFLhxD+kqhN1mhxYmoaKmkDLS1Mzelbt96doqtCEjz/XzWPrtNJw7r2DOgOnzARnq 33 | 73VvAEEFotlmAoy6zMLiPMxxITdCUmeCbBn7IZOuU0lWW/mmzBy3jBCa2oFuNBROgXBl92fkIYbQ 34 | 5Qq9ECnYxd3iZuCPyn4i41RTpQlWHnB9aXvNxM7xm9KJnGBvfYfd+lAZGHBTlMuEaEoixwUlqsZA 35 | FBWdJeLfV+AKFchaVlb25kSZOms68pISa0EedNG90kPNZENyTTU/gDWYbby6eeLmoFCoVPUTptzl 36 | qGnby/gEFSiQTsqfGN0BUh5rABWrEBkxXHURIzFlzxZ/LI35r7wtA9ys8x8HNOIgbjbjMsayuh10 37 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9uWy 105 | WcPq+wRlzwu4fZSZZBwV4xt4mXmwjTKuzD1QLuxDbvSBm2gpMcYpBBsA4HfjPPia5Imr5YjssLJh 106 | P7PA5Zl7GNi7gEqzl2kHTne5m61jm2X3DpvNqNBjs9F7LAF04blTK58j1f410FDJ4h/tQbp9uEm6 107 | MfTKoxnzYd+Lf/UpIfKpHCdlh+yzcNXMXCI=`, 108 | } 109 | 110 | type PackageKey = string 111 | type UserKey = string 112 | 113 | type Package struct { 114 | UID int `json:"uid"` 115 | GID int `json:"gid"` 116 | User string `json:"user"` 117 | Package string `json:"package"` 118 | Enabled bool `json:"enabled"` 119 | } 120 | 121 | type User struct { 122 | UID int `json:"uid"` 123 | GID int `json:"gid"` 124 | User string `json:"user"` 125 | Enabled bool `json:"enabled"` 126 | } 127 | 128 | type Permission struct { 129 | Packages map[PackageKey]Package `json:"packages"` 130 | Users map[UserKey]User `json:"users"` 131 | } 132 | 133 | type Signature struct { 134 | Version int `json:"version"` 135 | Signature string `json:"signature"` 136 | PublicKeys []PublicKey `json:"publicKeys"` 137 | } 138 | 139 | type PublicKey struct { 140 | PublicKey string `json:"publicKey"` 141 | Signature string `json:"signature"` 142 | } 143 | 144 | type Config struct { 145 | TrustSignature bool `json:"trustSignature"` 146 | } 147 | 148 | type PermissionChecker struct { 149 | commandAndArgs []string 150 | uid int 151 | } 152 | 153 | func loadPermissionConfig() (*Permission, error) { 154 | fileContent, err := os.ReadFile(permissionsPath) 155 | if err != nil { 156 | return nil, err 157 | } 158 | 159 | var permissions Permission 160 | err = json.Unmarshal(fileContent, &permissions) 161 | if err != nil { 162 | return nil, err 163 | } 164 | 165 | return &permissions, nil 166 | } 167 | 168 | func loadConfig() (*Config, error) { 169 | fileContent, err := os.ReadFile(configPath) 170 | if err != nil { 171 | return nil, err 172 | } 173 | 174 | var config Config 175 | err = json.Unmarshal(fileContent, &config) 176 | if err != nil { 177 | return nil, err 178 | } 179 | 180 | return &config, nil 181 | } 182 | 183 | func loadSignature(path string) (*Signature, error) { 184 | fileContent, err := os.ReadFile(path) 185 | if err != nil { 186 | return nil, err 187 | } 188 | 189 | var signature Signature 190 | err = json.Unmarshal(fileContent, &signature) 191 | if err != nil { 192 | return nil, err 193 | } 194 | 195 | return &signature, nil 196 | } 197 | 198 | func (p *PermissionChecker) isUIDPermissionOK() bool { 199 | permissions, err := loadPermissionConfig() 200 | if err != nil { 201 | _, _ = fmt.Fprintf(os.Stderr, "load config failed: %s\n", err) 202 | return false 203 | } 204 | 205 | for _, pkg := range permissions.Packages { 206 | if pkg.UID == p.uid { 207 | if pkg.Enabled { 208 | audit.AddPackageApproved(p.commandAndArgs[0], p.uid, pkg.Package) 209 | } 210 | return pkg.Enabled 211 | } 212 | } 213 | 214 | for _, u := range permissions.Users { 215 | if u.UID == p.uid { 216 | if u.Enabled { 217 | audit.AddUserApproved(p.commandAndArgs[0], p.uid) 218 | } 219 | return u.Enabled 220 | } 221 | } 222 | return false 223 | } 224 | 225 | func isSignatureMatched(pubKey []byte, data []byte, signature []byte) (keyID string, err error) { 226 | pgpSignature := crypto.NewPGPSignature(signature) 227 | 228 | publicKeyObj, err := crypto.NewKey(pubKey) 229 | if err != nil { 230 | return "", err 231 | } 232 | 233 | signingKeyRing, err := crypto.NewKeyRing(publicKeyObj) 234 | if err != nil { 235 | return "", err 236 | } 237 | 238 | for key := range publicKeyObj.GetEntity().Identities { 239 | keyID = key 240 | break 241 | } 242 | 243 | err = signingKeyRing.VerifyDetached(crypto.NewPlainMessage(data), pgpSignature, crypto.GetUnixTime()) 244 | return keyID, err 245 | } 246 | 247 | func isSignatureMatchedBase64(pubKey string, data []byte, signature string) (keyID string, err error) { 248 | pubKeyBin, err := base64.StdEncoding.DecodeString(pubKey) 249 | if err != nil { 250 | return "", err 251 | } 252 | 253 | signatureBin, err := base64.StdEncoding.DecodeString(signature) 254 | if err != nil { 255 | return "", err 256 | } 257 | 258 | return isSignatureMatched(pubKeyBin, data, signatureBin) 259 | } 260 | 261 | func (p *PermissionChecker) verifySignature(signature *Signature, data []byte) error { 262 | var err error 263 | for _, pk := range rootPubKeys { 264 | err = p.verifySignatureBySingleRootKey(pk, signature, data) 265 | if err == nil { 266 | return nil 267 | } 268 | } 269 | 270 | return err 271 | } 272 | 273 | func (p *PermissionChecker) verifySignatureBySingleRootKey(rootPubKey string, signature *Signature, data []byte) error { 274 | pubKey := rootPubKey 275 | 276 | // verify middle public keys 277 | for _, pk := range signature.PublicKeys { 278 | pkData, err := base64.StdEncoding.DecodeString(pk.PublicKey) 279 | if err != nil { 280 | return err 281 | } 282 | _, err = isSignatureMatchedBase64(pubKey, pkData, pk.Signature) 283 | if err != nil { 284 | return err 285 | } 286 | pubKey = pk.PublicKey 287 | } 288 | 289 | keyID, err := isSignatureMatchedBase64(pubKey, data, signature.Signature) 290 | if err == nil { 291 | audit.AddSignatureApproved(p.commandAndArgs[0], p.uid, keyID) 292 | } 293 | return err 294 | } 295 | 296 | func (p *PermissionChecker) isCommandSignatureOK(commandPath, sigPath string) bool { 297 | signature, err := loadSignature(sigPath) 298 | if err != nil { 299 | _, _ = fmt.Fprintf(os.Stderr, "load signature failed: %s\n", err) 300 | return false 301 | } 302 | 303 | data, err := os.ReadFile(commandPath) 304 | if err != nil { 305 | return false 306 | } 307 | 308 | err = p.verifySignature(signature, data) 309 | if err != nil { 310 | _, _ = fmt.Fprintf(os.Stderr, "verify signature failed: %s\n", err) 311 | } 312 | return err == nil 313 | } 314 | 315 | func (p *PermissionChecker) checkPermission() (_user *user.User) { 316 | if len(p.commandAndArgs) < 1 { 317 | _, _ = fmt.Fprintf(os.Stderr, "missing command") 318 | os.Exit(1) 319 | } 320 | 321 | var err error 322 | 323 | p.uid = os.Getuid() 324 | 325 | _user, err = user.LookupId(fmt.Sprintf("%d", p.uid)) 326 | if err != nil { 327 | _, _ = fmt.Fprintf(os.Stderr, "%s\n", err) 328 | os.Exit(1) 329 | } 330 | 331 | if p.uid == 0 { 332 | return 333 | } 334 | 335 | setuidErr := syscall.Setuid(0) 336 | if setuidErr != nil { 337 | _, _ = fmt.Fprintf(os.Stderr, "%s\n", setuidErr) 338 | os.Exit(1) 339 | } 340 | 341 | if p.isUIDPermissionOK() { 342 | return 343 | } 344 | 345 | var ( 346 | sigPath string 347 | config *Config 348 | cmd = p.commandAndArgs[0] 349 | ) 350 | 351 | sigPath = cmd + ".sig" 352 | stat, _ := os.Stat(sigPath) 353 | if stat == nil { 354 | _, _ = fmt.Fprintf(os.Stderr, "user with uid %d is not in permitted list and there is no signature for %s\n", p.uid, cmd) 355 | goto ErrPermission 356 | } 357 | 358 | config, err = loadConfig() 359 | if err != nil { 360 | _, _ = fmt.Fprintf(os.Stderr, "load config failed: %s\n", err) 361 | goto ErrPermission 362 | } 363 | 364 | if !config.TrustSignature { 365 | _, _ = fmt.Fprintf(os.Stderr, "TrustSignature feature is disabled\n") 366 | goto ErrPermission 367 | } 368 | 369 | if p.isCommandSignatureOK(cmd, sigPath) { 370 | return 371 | } 372 | _, _ = fmt.Fprintf(os.Stderr, "%s signature is not match\n", cmd) 373 | 374 | ErrPermission: 375 | _, _ = fmt.Fprintf(os.Stderr, "%s\n", os.ErrPermission) 376 | audit.AddDenied(cmd, p.uid) 377 | os.Exit(1) 378 | return 379 | } 380 | 381 | func parseArgs(args []string) (spmArgs []string, commandAndArgs []string) { 382 | for i := 0; i < len(args); i++ { 383 | if args[i] == "--" { 384 | if len(args) > i+1 { 385 | commandAndArgs = args[i+1:] 386 | } 387 | return 388 | } 389 | 390 | // special case for help 391 | if args[i] == "-h" || args[i] == "--h" || args[i] == "-help" || args[i] == "--help" { 392 | spmArgs = append(spmArgs, args[i]) 393 | continue 394 | } 395 | 396 | // for other twinning args 397 | if strings.HasPrefix(args[i], "-") { 398 | if len(args) > i+1 { 399 | spmArgs = append(spmArgs, args[i]) 400 | spmArgs = append(spmArgs, args[i+1]) 401 | i++ 402 | } 403 | continue 404 | } 405 | 406 | if len(args) > i { 407 | commandAndArgs = args[i:] 408 | } 409 | return 410 | } 411 | return 412 | } 413 | 414 | func runCommand(user *user.User, commandAndArgs []string, pid *string) { 415 | subProcess := exec.Command(commandAndArgs[0], commandAndArgs[1:]...) 416 | subProcess.Stdin = os.Stdin 417 | subProcess.Stdout = os.Stdout 418 | subProcess.Stderr = os.Stderr 419 | 420 | err := subProcess.Start() 421 | if err != nil { 422 | fmt.Fprint(os.Stderr, err.Error()) 423 | goto exit 424 | } 425 | 426 | if pid != nil { 427 | _ = syscall.Umask(0) 428 | _ = os.WriteFile(*pid, []byte(fmt.Sprintf("%d", subProcess.Process.Pid)), 0644) 429 | uid, _ := strconv.Atoi(user.Uid) 430 | gid, _ := strconv.Atoi(user.Gid) 431 | _ = os.Chown(*pid, uid, gid) 432 | } 433 | 434 | _ = subProcess.Wait() 435 | 436 | exit: 437 | os.Exit(subProcess.ProcessState.ExitCode()) 438 | } 439 | 440 | func main() { 441 | var pid *string 442 | 443 | spmArgs, commandAndArgs := parseArgs(os.Args[1:]) 444 | 445 | if len(spmArgs) > 0 { 446 | fs := flag.NewFlagSet("spm", flag.ExitOnError) 447 | pid = fs.String("pid", "", "path to store command pid") 448 | fs.Parse(spmArgs) 449 | } 450 | 451 | checker := &PermissionChecker{ 452 | commandAndArgs: commandAndArgs, 453 | } 454 | 455 | user := checker.checkPermission() 456 | 457 | runCommand(user, commandAndArgs, pid) 458 | } 459 | -------------------------------------------------------------------------------- /src/app/SimplePermissionManager.js: -------------------------------------------------------------------------------- 1 | // Namespace definition 2 | Ext.ns("SynoCommunity.SimplePermissionManager"); 3 | 4 | // Application definition 5 | Ext.define("SynoCommunity.SimplePermissionManager.AppInstance", { 6 | extend: "SYNO.SDS.AppInstance", 7 | appWindowName: "SynoCommunity.SimplePermissionManager.AppWindow", 8 | constructor: function () { 9 | this.callParent(arguments); 10 | }, 11 | }); 12 | 13 | // Translator 14 | _V = function (category, element) { 15 | return _TT("SynoCommunity.SimplePermissionManager.AppInstance", category, element) 16 | } 17 | 18 | // Window definition 19 | Ext.define("SynoCommunity.SimplePermissionManager.AppWindow", { 20 | extend: "SYNO.SDS.AppWindow", 21 | appInstance: null, 22 | tabs: null, 23 | onOpen: function (a) { 24 | SynoCommunity.SimplePermissionManager.AppWindow.superclass.onOpen.call( 25 | this, 26 | a 27 | ); 28 | }, 29 | constructor: function (config) { 30 | this.appInstance = config.appInstance; 31 | 32 | this.tabs = function () { 33 | var allTabs = []; 34 | 35 | allTabs.push({ 36 | title: _V("ui", "overview"), 37 | items: [ 38 | this.createDisplayStatus(), 39 | this.createDisplayConfig(), 40 | ], 41 | }); 42 | 43 | allTabs.push({ 44 | title: _V("ui", "packages"), 45 | layout: "fit", 46 | items: [this.createPackageGrid()], 47 | }); 48 | 49 | allTabs.push({ 50 | title: _V("ui", "users"), 51 | layout: "fit", 52 | items: [this.createUserGrid()], 53 | }); 54 | 55 | allTabs.push({ 56 | title: _V("ui", "audit_logs"), 57 | layout: "fit", 58 | items: [this.createAuditLogsGrid()], 59 | }); 60 | 61 | return allTabs; 62 | }.call(this); 63 | 64 | config = Ext.apply( 65 | { 66 | resizable: true, 67 | maximizable: true, 68 | minimizable: true, 69 | width: 640, 70 | height: 510, 71 | padding: "15px", 72 | items: [ 73 | { 74 | xtype: "syno_tabpanel", 75 | activeTab: 0, 76 | plain: true, 77 | items: this.tabs, 78 | deferredRender: true, 79 | }, 80 | ], 81 | }, 82 | config 83 | ); 84 | 85 | this.callParent([config]); 86 | }, 87 | // Create the display of status 88 | createDisplayStatus: function () { 89 | spmStatusItem = { 90 | id: "active_status", 91 | xtype: "syno_displayfield", 92 | value: _V("ui", "status_unknown"), 93 | width: 140, 94 | }; 95 | spmStatus = { 96 | active: false, 97 | major: 0, 98 | minor: 0, 99 | base: 0, 100 | } 101 | Ext.Ajax.request({ 102 | url: "/webman/3rdparty/SimplePermissionManager/cgi/status.cgi", 103 | method: "GET", 104 | async: false, 105 | timeout: 60000, 106 | success: function (response) { 107 | spmStatus = Ext.decode(response.responseText); 108 | if (spmStatus.active) { 109 | spmStatusItem.value = _V("ui", "status_active"); 110 | spmStatusItem.style = { 111 | color: "green", 112 | }; 113 | } else { 114 | spmStatusItem.value = _V("ui", "status_inactive"); 115 | } 116 | }, 117 | failure: function (response) { 118 | window.alert("Fetch Status Failed."); 119 | }, 120 | }); 121 | 122 | activeItem = { 123 | id: "active_button", 124 | xtype: "syno_button", 125 | btnStyle: "blue", 126 | text: _V("ui", "active"), 127 | hidden: spmStatus.active, 128 | handler: this.onActive.bind(this), 129 | }; 130 | 131 | if (spmStatus.major == 7){ 132 | if (spmStatus.minor == 0 || spmStatus.minor == 1){ 133 | activeItem.handler = this.onActiveDirectly.bind(this); 134 | } 135 | } 136 | 137 | return new SYNO.ux.FieldSet({ 138 | title: _V("ui", "status"), 139 | collapsible: false, 140 | items: [ 141 | { 142 | xtype: "syno_compositefield", 143 | hideLabel: true, 144 | items: [ 145 | { 146 | xtype: "syno_displayfield", 147 | value: _V("ui", "status") + _T("common", "pure_colon"), 148 | width: 140, 149 | }, 150 | spmStatusItem, 151 | activeItem, 152 | ], 153 | }, 154 | ], 155 | }); 156 | }, 157 | // Create the display of config 158 | createDisplayConfig: function () { 159 | config = {}; 160 | Ext.Ajax.request({ 161 | url: "/webman/3rdparty/SimplePermissionManager/cgi/config.cgi", 162 | method: "GET", 163 | async: false, 164 | timeout: 60000, 165 | success: function (response) { 166 | config = Ext.decode(response.responseText); 167 | }, 168 | failure: function (response) { 169 | window.alert("Fetch Config Failed."); 170 | }, 171 | }); 172 | return new SYNO.ux.FieldSet({ 173 | title: _V("ui", "configure"), 174 | collapsible: false, 175 | items: [ 176 | { 177 | xtype: "syno_compositefield", 178 | hideLabel: true, 179 | items: [ 180 | { 181 | xtype: "syno_displayfield", 182 | value: _V("ui", "trust_signature") + _T("common", "pure_colon"), 183 | width: 140, 184 | }, 185 | { 186 | xtype: "syno_checkbox", 187 | boxLabel: " ", 188 | id: "valid_signature", 189 | checked: config.trustSignature, 190 | readOnly: true, 191 | }, 192 | ], 193 | }, 194 | ], 195 | }); 196 | }, 197 | fetchSynoConfirmPWToken: function (callback) { 198 | this.sendWebAPI({ 199 | api: "SYNO.Core.User.PasswordConfirm", 200 | method: "auth", 201 | version: 2, 202 | params: { 203 | password: Ext.getCmp("confirm_password").getValue(), 204 | }, 205 | callback: function (success, response) { 206 | if (!success) { 207 | window.alert("invalid admin password"); 208 | return; 209 | } 210 | 211 | if ( 212 | response.SynoConfirmPWToken === null || 213 | (typeof response.SynoConfirmPWToken === "string" && 214 | response.SynoConfirmPWToken.trim() === "") 215 | ) { 216 | console.log("empty SynoConfirmPWToken"); 217 | return; 218 | } 219 | 220 | callback(response.SynoConfirmPWToken); 221 | }, 222 | scope: this, 223 | }); 224 | }, 225 | sendCreateSchedulerTaskWebAPI: function (token) { 226 | params = { 227 | task_name: "Active Simple Permission Manager", 228 | owner: { 0: "root" }, 229 | event: "bootup", 230 | enable: true, 231 | depend_on_task: "", 232 | notify_enable: false, 233 | notify_mail: "", 234 | notify_if_error: false, 235 | operation_type: "script", 236 | operation: "spm-update", 237 | }; 238 | 239 | if (token != "") { 240 | params.SynoConfirmPWToken = token 241 | } 242 | 243 | args = { 244 | // api: "SYNO.Core.EventScheduler.Root", 245 | method: "create", 246 | version: 1, 247 | params: params, 248 | callback: function (success, message) { 249 | if (!success) { 250 | console.log("error create EventScheduler task"); 251 | return; 252 | } 253 | 254 | if (token != "") { 255 | this.runSchedulerTask(); 256 | } else { 257 | this.sendRunSchedulerTaskWebAPI(""); 258 | } 259 | }, 260 | scope: this, 261 | } 262 | 263 | if (token != "") { 264 | args.api = "SYNO.Core.EventScheduler.Root" 265 | } else { 266 | args.api = "SYNO.Core.EventScheduler" 267 | } 268 | 269 | this.sendWebAPI(args); 270 | }, 271 | createAndRunSchedulerTask: function () { 272 | this.fetchSynoConfirmPWToken( 273 | this.sendCreateSchedulerTaskWebAPI.bind(this) 274 | ); 275 | }, 276 | sendRunSchedulerTaskWebAPI: function (token) { 277 | args = { 278 | api: "SYNO.Core.EventScheduler", 279 | method: "run", 280 | version: 1, 281 | params: { 282 | task_name: "Active Simple Permission Manager", 283 | }, 284 | callback: function (success, message, data) { 285 | if (!success) { 286 | console.log("error run EventScheduler task"); 287 | return; 288 | } 289 | 290 | if (token != "") { 291 | this.deleteSchedulerTask(); 292 | } else { 293 | this.sendDeleteSchedulerTaskWebAPI(""); 294 | } 295 | }, 296 | scope: this, 297 | }; 298 | 299 | if (token != "") { 300 | params.SynoConfirmPWToken = token 301 | } 302 | this.sendWebAPI(args); 303 | }, 304 | runSchedulerTask: function () { 305 | this.fetchSynoConfirmPWToken( 306 | this.sendRunSchedulerTaskWebAPI.bind(this) 307 | ); 308 | }, 309 | sendDeleteSchedulerTaskWebAPI: function (token) { 310 | args = { 311 | api: "SYNO.Core.EventScheduler", 312 | method: "delete", 313 | version: 1, 314 | params: { 315 | task_name: "Active Simple Permission Manager", 316 | }, 317 | callback: function (success, message, data) { 318 | if (!success) { 319 | console.log("error delete EventScheduler task"); 320 | return; 321 | } 322 | 323 | if (token != "") { 324 | Ext.getCmp("confirm_password_dialog").close(); 325 | } 326 | Ext.getCmp("active_button").hide(); 327 | Ext.getCmp("active_status").setValue("Active"); 328 | const element = document.getElementById("active_status"); 329 | element.style.color = "green"; 330 | }, 331 | scope: this, 332 | } 333 | 334 | if (token != "") { 335 | args.params.SynoConfirmPWToken = token 336 | } 337 | 338 | this.sendWebAPI(args); 339 | }, 340 | deleteSchedulerTask: function () { 341 | this.fetchSynoConfirmPWToken( 342 | this.sendDeleteSchedulerTaskWebAPI.bind(this) 343 | ); 344 | }, 345 | // Call Active on click 346 | onActive: function () { 347 | var window = new SYNO.SDS.ModalWindow({ 348 | id: "confirm_password_dialog", 349 | title: _T("common", "enter_password_to_continue"), 350 | width: 500, 351 | height: 200, 352 | resizable: !1, 353 | layout: "fit", 354 | buttons: [ 355 | { 356 | xtype: "syno_button", 357 | text: _T("common", "alt_cancel"), 358 | scope: this, 359 | handler: function () { 360 | Ext.getCmp("confirm_password_dialog").close(); 361 | }, 362 | }, 363 | { 364 | xtype: "syno_button", 365 | text: _T("common", "submit"), 366 | btnStyle: "blue", 367 | scope: this, 368 | handler: this.createAndRunSchedulerTask.bind(this), 369 | }, 370 | ], 371 | items: [ 372 | { 373 | xtype: "syno_formpanel", 374 | id: "password_form_panel", 375 | bodyStyle: "padding: 0", 376 | items: [ 377 | { 378 | xtype: "syno_displayfield", 379 | value: String.format( 380 | _T("common", "enter_user_password") 381 | ), 382 | }, 383 | { 384 | xtype: "syno_textfield", 385 | fieldLabel: _T("common", "password"), 386 | textType: "password", 387 | id: "confirm_password", 388 | }, 389 | ], 390 | }, 391 | ], 392 | }); 393 | window.open(); 394 | }, 395 | // Call Active on click 396 | onActiveDirectly: function () { 397 | this.sendCreateSchedulerTaskWebAPI(""); 398 | }, 399 | // Grid search 400 | createFilter: function (gridStore) { 401 | var searchField = new SYNO.ux.TextFilter({ 402 | emptyText: "Search", 403 | store: gridStore, 404 | pageSize: 5, 405 | width: 300, 406 | }); 407 | 408 | var toolbar = new SYNO.ux.Toolbar({ 409 | items: [searchField], 410 | }); 411 | 412 | return toolbar; 413 | }, 414 | // Create JSON Store grid calling list packages API 415 | createPackageGrid: function () { 416 | var localUrl = 417 | "/webman/3rdparty/SimplePermissionManager/cgi/list-packages.cgi"; 418 | 419 | var gridStore = new SYNO.API.JsonStore({ 420 | autoDestroy: true, 421 | url: localUrl, 422 | restful: true, 423 | root: "result", 424 | idProperty: "package", 425 | fields: [ 426 | { 427 | name: "enabled", 428 | type: "boolean", 429 | }, 430 | // { 431 | // name: "id", 432 | // type: "int", 433 | // }, 434 | { 435 | name: "package", 436 | type: "string", 437 | }, 438 | { 439 | name: "version", 440 | type: "string", 441 | }, 442 | { 443 | name: "description", 444 | type: "string", 445 | }, 446 | ], 447 | }); 448 | 449 | var paging = new SYNO.ux.PagingToolbar({ 450 | store: gridStore, 451 | displayInfo: true, 452 | pageSize: 10, 453 | refreshText: "Reload", 454 | }); 455 | 456 | // var checkboxSelModel = new Ext.grid.CheckboxSelectionModel({ 457 | // width: 30, 458 | // dataIndex: "enabled", 459 | // renderer: function(b, c, a) { 460 | // return '
 
' 461 | // }, 462 | // listeners: { 463 | // selectionchange: { 464 | // fn: function (e) { 465 | // console.log(e); 466 | // }, 467 | // scope: this, 468 | // }, 469 | // }, 470 | // }); 471 | var enableColumn = new SYNO.ux.EnableColumn({ 472 | // header: _T("common", "enabled"), 473 | dataIndex: "enabled", 474 | width: 20, 475 | align: "center", 476 | bindRowClick: true, 477 | commitChanges: true, 478 | disableSelectAll: true, 479 | enableFastSelectAll: false, 480 | toggleRec: function(t) { 481 | var v = t.get(this.dataIndex); 482 | t.set(this.dataIndex, !v); 483 | t.json.enabled = !v; 484 | 485 | Ext.Ajax.request({ 486 | url: "/webman/3rdparty/SimplePermissionManager/cgi/update-package.cgi", 487 | method: "POST", 488 | timeout: 60000, 489 | jsonData: { 490 | package: t.json.package, 491 | enabled: !v, 492 | }, 493 | success: function (response) { 494 | var result = response.responseText; 495 | console.log("update-package.cgi response :\n" + result); 496 | }, 497 | failure: function (response) { 498 | window.alert("Request Failed."); 499 | }, 500 | }); 501 | }, 502 | }); 503 | 504 | var c = { 505 | store: gridStore, 506 | plugins: [enableColumn], 507 | colModel: new Ext.grid.ColumnModel({ 508 | defaults: { 509 | sortable: true, 510 | menuDisabled: true, 511 | width: 100, 512 | height: 20, 513 | }, 514 | columns: [ 515 | // checkboxSelModel, 516 | enableColumn, 517 | // { 518 | // header: "Enabled", 519 | // width: 30, 520 | // dataIndex: "enabled", 521 | // }, 522 | // { 523 | // header: "Index", 524 | // width: 30, 525 | // dataIndex: "id", 526 | // }, 527 | { 528 | header: "Package Name", 529 | width: 150, 530 | dataIndex: "package", 531 | }, 532 | { 533 | header: "Version", 534 | width: 100, 535 | dataIndex: "version", 536 | }, 537 | ], 538 | }), 539 | selModel: new Ext.grid.RowSelectionModel(), 540 | viewConfig: { 541 | forceFit: true, 542 | onLoad: Ext.emptyFn, 543 | listeners: { 544 | beforerefresh: function (f) { 545 | f.scrollTop = f.scroller.dom.scrollTop; 546 | }, 547 | refresh: function (f) { 548 | f.scroller.dom.scrollTop = f.scrollTop; 549 | }, 550 | }, 551 | }, 552 | columnLines: true, 553 | frame: false, 554 | bbar: paging, 555 | height: 385, 556 | cls: "resource-monitor-performance", 557 | listeners: { 558 | scope: this, 559 | render: function (grid) { 560 | grid.getStore().load({ 561 | params: { 562 | offset: 0, 563 | limit: 10, 564 | }, 565 | }); 566 | }, 567 | }, 568 | }; 569 | 570 | return new SYNO.ux.GridPanel(c); 571 | }, 572 | // Create JSON Store grid calling list user API 573 | createUserGrid: function () { 574 | var localUrl = 575 | "/webman/3rdparty/SimplePermissionManager/cgi/list-users.cgi"; 576 | 577 | var gridStore = new SYNO.API.JsonStore({ 578 | autoDestroy: true, 579 | url: localUrl, 580 | restful: true, 581 | root: "result", 582 | idProperty: "name", 583 | fields: [ 584 | { 585 | name: "enabled", 586 | type: "boolean", 587 | }, 588 | { 589 | name: "name", 590 | type: "string", 591 | }, 592 | { 593 | name: "uid", 594 | type: "int", 595 | }, 596 | { 597 | name: "gid", 598 | type: "int", 599 | }, 600 | ], 601 | }); 602 | 603 | var paging = new SYNO.ux.PagingToolbar({ 604 | store: gridStore, 605 | displayInfo: true, 606 | pageSize: 10, 607 | refreshText: "Reload", 608 | }); 609 | 610 | var enableColumn = new SYNO.ux.EnableColumn({ 611 | dataIndex: "enabled", 612 | width: 20, 613 | align: "center", 614 | bindRowClick: true, 615 | commitChanges: true, 616 | disableSelectAll: true, 617 | enableFastSelectAll: false, 618 | toggleRec: function(t) { 619 | var v = t.get(this.dataIndex); 620 | t.set(this.dataIndex, !v); 621 | t.json.enabled = !v; 622 | 623 | Ext.Ajax.request({ 624 | url: "/webman/3rdparty/SimplePermissionManager/cgi/update-user.cgi", 625 | method: "POST", 626 | timeout: 60000, 627 | jsonData: { 628 | name: t.json.name, 629 | enabled: !v, 630 | }, 631 | success: function (response) { 632 | var result = response.responseText; 633 | console.log("update-user.cgi response :\n" + result); 634 | }, 635 | failure: function (response) { 636 | window.alert("Request Failed."); 637 | }, 638 | }); 639 | }, 640 | }); 641 | 642 | var c = { 643 | store: gridStore, 644 | plugins: [enableColumn], 645 | colModel: new Ext.grid.ColumnModel({ 646 | defaults: { 647 | sortable: true, 648 | menuDisabled: true, 649 | width: 100, 650 | height: 20, 651 | }, 652 | columns: [ 653 | enableColumn, 654 | { 655 | header: "User ID", 656 | width: 50, 657 | dataIndex: "uid", 658 | }, 659 | { 660 | header: "User Name", 661 | width: 100, 662 | dataIndex: "name", 663 | }, 664 | { 665 | header: "Group ID", 666 | width: 100, 667 | dataIndex: "gid", 668 | }, 669 | ], 670 | }), 671 | selModel: new Ext.grid.RowSelectionModel(), 672 | viewConfig: { 673 | forceFit: true, 674 | onLoad: Ext.emptyFn, 675 | listeners: { 676 | beforerefresh: function (f) { 677 | f.scrollTop = f.scroller.dom.scrollTop; 678 | }, 679 | refresh: function (f) { 680 | f.scroller.dom.scrollTop = f.scrollTop; 681 | }, 682 | }, 683 | }, 684 | columnLines: true, 685 | frame: false, 686 | bbar: paging, 687 | height: 385, 688 | cls: "resource-monitor-performance", 689 | listeners: { 690 | scope: this, 691 | render: function (grid) { 692 | grid.getStore().load({ 693 | params: { 694 | offset: 0, 695 | limit: 10, 696 | }, 697 | }); 698 | }, 699 | }, 700 | }; 701 | 702 | return new SYNO.ux.GridPanel(c); 703 | }, 704 | // Create JSON Store grid calling list audit logs API 705 | createAuditLogsGrid: function () { 706 | var localUrl = 707 | "/webman/3rdparty/SimplePermissionManager/cgi/list-audit-logs.cgi"; 708 | 709 | var gridStore = new SYNO.API.JsonStore({ 710 | autoDestroy: true, 711 | url: localUrl, 712 | restful: true, 713 | root: "result", 714 | idProperty: "id", 715 | fields: [ 716 | { 717 | name: "id", 718 | type: "int", 719 | }, 720 | { 721 | name: "command", 722 | type: "string", 723 | }, 724 | { 725 | name: "uid", 726 | type: "int", 727 | }, 728 | { 729 | name: "package", 730 | type: "string", 731 | }, 732 | { 733 | name: "action", 734 | type: "int", 735 | }, 736 | { 737 | name: "reason", 738 | type: "string", 739 | }, 740 | ], 741 | }); 742 | 743 | var paging = new SYNO.ux.PagingToolbar({ 744 | store: gridStore, 745 | displayInfo: true, 746 | pageSize: 10, 747 | refreshText: "Reload", 748 | }); 749 | 750 | var c = { 751 | store: gridStore, 752 | colModel: new Ext.grid.ColumnModel({ 753 | defaults: { 754 | sortable: true, 755 | menuDisabled: true, 756 | width: 100, 757 | height: 20, 758 | }, 759 | columns: [ 760 | { 761 | header: "ID", 762 | width: 30, 763 | dataIndex: "id", 764 | }, 765 | { 766 | header: "User ID", 767 | width: 50, 768 | dataIndex: "uid", 769 | }, 770 | { 771 | header: "Command", 772 | width: 80, 773 | dataIndex: "command", 774 | }, 775 | { 776 | header: "Package", 777 | width: 150, 778 | dataIndex: "package", 779 | }, 780 | { 781 | header: "Action", 782 | width: 30, 783 | dataIndex: "action", 784 | }, 785 | { 786 | header: "Reason", 787 | width: 100, 788 | dataIndex: "reason", 789 | }, 790 | ], 791 | }), 792 | selModel: new Ext.grid.RowSelectionModel(), 793 | viewConfig: { 794 | forceFit: true, 795 | onLoad: Ext.emptyFn, 796 | listeners: { 797 | beforerefresh: function (f) { 798 | f.scrollTop = f.scroller.dom.scrollTop; 799 | }, 800 | refresh: function (f) { 801 | f.scroller.dom.scrollTop = f.scrollTop; 802 | }, 803 | }, 804 | }, 805 | columnLines: true, 806 | frame: false, 807 | bbar: paging, 808 | height: 385, 809 | cls: "resource-monitor-performance", 810 | listeners: { 811 | scope: this, 812 | render: function (grid) { 813 | grid.getStore().load({ 814 | params: { 815 | offset: 0, 816 | limit: 10, 817 | }, 818 | }); 819 | }, 820 | }, 821 | }; 822 | 823 | return new SYNO.ux.GridPanel(c); 824 | }, 825 | }); 826 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . --------------------------------------------------------------------------------