working commit
This commit is contained in:
+3
-6
@@ -126,17 +126,14 @@ run:
|
|||||||
env CGO_ENABLED=1 $(GO) run $(GOFLAGS) ./cmd/mbased/... --daemon=false
|
env CGO_ENABLED=1 $(GO) run $(GOFLAGS) ./cmd/mbased/... --daemon=false
|
||||||
|
|
||||||
|
|
||||||
distclean-local: clean
|
distclean-local:
|
||||||
rm -rf autom4te.cache
|
rm -rf tmp/
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -f */*/*~
|
$(FIND) . -name "*~" | $(XARGS) rm -v
|
||||||
rm -f */*~
|
|
||||||
rm -f *~
|
|
||||||
rm -f cmd/mbaseadmin/mbaseadmin
|
rm -f cmd/mbaseadmin/mbaseadmin
|
||||||
rm -f cmd/mbasectl/mbasectl
|
rm -f cmd/mbasectl/mbasectl
|
||||||
rm -f cmd/mbased/mbased
|
rm -f cmd/mbased/mbased
|
||||||
rm -f cmd/mbasedump/mbasedump
|
rm -f cmd/mbasedump/mbasedump
|
||||||
rm -rf autom4te.cache
|
rm -rf autom4te.cache
|
||||||
rm -rf tmp/
|
|
||||||
|
|
||||||
|
|||||||
+4
-6
@@ -225,6 +225,7 @@ ECHO_N = @ECHO_N@
|
|||||||
ECHO_T = @ECHO_T@
|
ECHO_T = @ECHO_T@
|
||||||
ETAGS = @ETAGS@
|
ETAGS = @ETAGS@
|
||||||
EXEEXT = @EXEEXT@
|
EXEEXT = @EXEEXT@
|
||||||
|
FIND = @FIND@
|
||||||
GO = @GO@
|
GO = @GO@
|
||||||
HAVE_GO = @HAVE_GO@
|
HAVE_GO = @HAVE_GO@
|
||||||
INSTALL = @INSTALL@
|
INSTALL = @INSTALL@
|
||||||
@@ -921,19 +922,16 @@ run:
|
|||||||
test -z $(DESTDIR)$(SRV_DATADIR) || $(MKDIR_P) $(DESTDIR)$(SRV_DATADIR)
|
test -z $(DESTDIR)$(SRV_DATADIR) || $(MKDIR_P) $(DESTDIR)$(SRV_DATADIR)
|
||||||
env CGO_ENABLED=1 $(GO) run $(GOFLAGS) ./cmd/mbased/... --daemon=false
|
env CGO_ENABLED=1 $(GO) run $(GOFLAGS) ./cmd/mbased/... --daemon=false
|
||||||
|
|
||||||
distclean-local: clean
|
distclean-local:
|
||||||
rm -rf autom4te.cache
|
rm -rf tmp/
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -f */*/*~
|
$(FIND) . -name "*~" | $(XARGS) rm -v
|
||||||
rm -f */*~
|
|
||||||
rm -f *~
|
|
||||||
rm -f cmd/mbaseadmin/mbaseadmin
|
rm -f cmd/mbaseadmin/mbaseadmin
|
||||||
rm -f cmd/mbasectl/mbasectl
|
rm -f cmd/mbasectl/mbasectl
|
||||||
rm -f cmd/mbased/mbased
|
rm -f cmd/mbased/mbased
|
||||||
rm -f cmd/mbasedump/mbasedump
|
rm -f cmd/mbasedump/mbasedump
|
||||||
rm -rf autom4te.cache
|
rm -rf autom4te.cache
|
||||||
rm -rf tmp/
|
|
||||||
|
|
||||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
|||||||
+24
-25
@@ -20,32 +20,30 @@ const (
|
|||||||
pidFilename = "mbased.pid"
|
pidFilename = "mbased.pid"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
buildVersion = "NONE"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Networks struct {
|
type Networks struct {
|
||||||
Enabled []string `json:"enabled" yaml:"enabled"`
|
Enabled []string `json:"enabled" yaml:"enabled"`
|
||||||
Disabled []string `json:"disabled" yaml:"disabled"`
|
Disabled []string `json:"disabled" yaml:"disabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServiceConfig struct {
|
type Service struct {
|
||||||
Portnum uint32 `json:"port" yaml:"port"`
|
Portnum uint32 `json:"port" yaml:"port"`
|
||||||
Address string `json:"address" yaml:"address"`
|
Address string `json:"address" yaml:"address"`
|
||||||
Protocol string `json:"protocol" yaml:"protocol"`
|
Protocol string `json:"protocol" yaml:"protocol"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
PackageVersion string `json:"packageVersion" yaml:"packageVersion"`
|
Version string `json:"version" yaml:"version"`
|
||||||
Service ServiceConfig `json:"service" yaml:"service"`
|
Service Service `json:"service" yaml:"service"`
|
||||||
Networks Networks `json:"networks" yaml:"networks"`
|
Networks Networks `json:"networks" yaml:"networks"`
|
||||||
Hostname string `json:"hostname" yaml:"hostname"`
|
Hostname string `json:"hostname" yaml:"hostname"`
|
||||||
Debug bool `json:"debug" yaml:"debug"`
|
Debug bool `json:"debug" yaml:"debug"`
|
||||||
Build string `json:"build" yaml:"build"`
|
Build string `json:"build" yaml:"build"`
|
||||||
LogPath string `json:"logfile" yaml:"logfile"`
|
LogPath string `json:"logfile" yaml:"logfile"`
|
||||||
RunPath string `json:"runfile" yaml:"runfile"`
|
RunPath string `json:"runfile" yaml:"runfile"`
|
||||||
DataDir string `json:"datadir" yaml:"datadir"`
|
DataDir string `json:"datadir" yaml:"datadir"`
|
||||||
Daemon bool `json:"daemon" yaml:"daemon"`
|
AsDaemon bool `json:"asDaemon" yaml:"asDaemon"`
|
||||||
|
RunUser string `json:"runUser" yaml:"runUser"`
|
||||||
|
LogLimit int64 `json:"logLimit" yaml:"logLimit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -54,28 +52,29 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultServiceAddress = "0.0.0.0"
|
defaultServiceAddress = "[::]"
|
||||||
defaultServiceProtocol = "tcp"
|
defaultServiceProtocol = "tcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
conf := &Config{
|
conf := &Config{
|
||||||
Service: ServiceConfig{
|
Service: Service{
|
||||||
Portnum: client.DefaultPort,
|
Portnum: client.DefaultPort,
|
||||||
Address: defaultServiceAddress,
|
Address: defaultServiceAddress,
|
||||||
Protocol: defaultServiceProtocol,
|
Protocol: defaultServiceProtocol,
|
||||||
},
|
},
|
||||||
DataDir: datadirPath,
|
|
||||||
Debug: false,
|
|
||||||
Hostname: defaultHostname,
|
|
||||||
Build: buildVersion,
|
|
||||||
Daemon: true,
|
|
||||||
PackageVersion: packageVersion,
|
|
||||||
|
|
||||||
Networks: Networks{
|
Networks: Networks{
|
||||||
Enabled: defaultEnabledNetworks,
|
Enabled: defaultEnabledNetworks,
|
||||||
Disabled: defaultDisabledNetworks,
|
Disabled: defaultDisabledNetworks,
|
||||||
},
|
},
|
||||||
|
DataDir: datadirPath,
|
||||||
|
Debug: false,
|
||||||
|
Hostname: defaultHostname,
|
||||||
|
Build: packageVersion,
|
||||||
|
AsDaemon: true,
|
||||||
|
Version: packageVersion,
|
||||||
|
LogLimit: 1024 * 1024 * 10, // 10 Mb
|
||||||
|
RunUser: "daemon",
|
||||||
}
|
}
|
||||||
conf.LogPath = filepath.Join(logdirPath, logFilename)
|
conf.LogPath = filepath.Join(logdirPath, logFilename)
|
||||||
conf.RunPath = filepath.Join(rundirPath, pidFilename)
|
conf.RunPath = filepath.Join(rundirPath, pidFilename)
|
||||||
@@ -106,7 +105,7 @@ func (conf *Config) ReadOpts() error {
|
|||||||
|
|
||||||
exeName := filepath.Base(os.Args[0])
|
exeName := filepath.Base(os.Args[0])
|
||||||
|
|
||||||
flag.BoolVar(&conf.Daemon, "daemon", conf.Daemon, "run as daemon")
|
flag.BoolVar(&conf.AsDaemon, "asDaemon", conf.AsDaemon, "run as daemon")
|
||||||
flag.BoolVar(&conf.Debug, "debug", conf.Debug, "on debug mode")
|
flag.BoolVar(&conf.Debug, "debug", conf.Debug, "on debug mode")
|
||||||
|
|
||||||
help := func() {
|
help := func() {
|
||||||
|
|||||||
@@ -10,34 +10,6 @@ import (
|
|||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const schema = `
|
|
||||||
--- DROP TABLE IF EXISTS account;
|
|
||||||
CREATE TABLE IF NOT EXISTS account (
|
|
||||||
id TEXT NOT NULL,
|
|
||||||
username TEXT NOT NULL,
|
|
||||||
passhash TEXT NOT NULL,
|
|
||||||
created_at TEXT NOT NULL,
|
|
||||||
updated_at TEXT NOT NULL,
|
|
||||||
disabled BOOL
|
|
||||||
);
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS account_index01
|
|
||||||
ON account(id);
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS account_index02
|
|
||||||
ON account(username);
|
|
||||||
|
|
||||||
--- DROP TABLE IF EXISTS grant;
|
|
||||||
CREATE TABLE IF NOT EXISTS grant (
|
|
||||||
id TEXT NOT NULL,
|
|
||||||
account_id TEXT NOT NULL,
|
|
||||||
operation TEXT NOT NULL,
|
|
||||||
created_at TEXT NOT NULL
|
|
||||||
);
|
|
||||||
CREATE INDEX IF NOT EXISTS grant_index01
|
|
||||||
ON grant(account_id);
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS grant_index02
|
|
||||||
ON grant(account_id, operation);
|
|
||||||
`
|
|
||||||
|
|
||||||
type Database struct {
|
type Database struct {
|
||||||
datapath string
|
datapath string
|
||||||
db *sqlx.DB
|
db *sqlx.DB
|
||||||
@@ -61,7 +33,6 @@ func (db *Database) OpenDatabase() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = db.db.Ping()
|
err = db.db.Ping()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+8
-8
@@ -8,9 +8,9 @@ import (
|
|||||||
|
|
||||||
func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
||||||
var err error
|
var err error
|
||||||
request := `INSERT INTO grant(id, account_id, operation, created_at)
|
request := `INSERT INTO grant(id, account_id, grantname, created_at)
|
||||||
VALUES ($1, $2, $3, $4)`
|
VALUES ($1, $2, $3, $4)`
|
||||||
_, err = db.db.Exec(request, grant.ID, grant.AccountID, grant.Operation, grant.CreatedAt)
|
_, err = db.db.Exec(request, grant.ID, grant.AccountID, grant.Grantname, grant.CreatedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -39,12 +39,12 @@ func (db *Database) ListGrants(ctx context.Context) ([]descr.Grant, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) GetGrant(ctx context.Context, accountID, operation string) (bool, *descr.Grant, error) {
|
func (db *Database) GetGrant(ctx context.Context, accountID, grantname string) (bool, *descr.Grant, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &descr.Grant{}
|
res := &descr.Grant{}
|
||||||
request := `SELECT * FROM grant WHERE account_id = $1 AND operation = $2 LIMIT 1`
|
request := `SELECT * FROM grant WHERE account_id = $1 AND grantname = $2 LIMIT 1`
|
||||||
dbRes := make([]descr.Grant, 0)
|
dbRes := make([]descr.Grant, 0)
|
||||||
err = db.db.Select(&dbRes, request, accountID, operation)
|
err = db.db.Select(&dbRes, request, accountID, grantname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, res, err
|
return false, res, err
|
||||||
}
|
}
|
||||||
@@ -56,10 +56,10 @@ func (db *Database) GetGrant(ctx context.Context, accountID, operation string) (
|
|||||||
return true, res, err
|
return true, res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID, operation string) error {
|
func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID, grantname string) error {
|
||||||
var err error
|
var err error
|
||||||
request := `DELETE FROM grant WHERE account_id = $1 AND operation = $2`
|
request := `DELETE FROM grant WHERE account_id = $1 AND grantname = $2`
|
||||||
_, err = db.db.Exec(request, grantID, operation)
|
_, err = db.db.Exec(request, grantID, grantname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package maindb
|
||||||
|
|
||||||
|
const schema = `
|
||||||
|
--- DROP TABLE IF EXISTS account;
|
||||||
|
CREATE TABLE IF NOT EXISTS account (
|
||||||
|
id TEXT NOT NULL,
|
||||||
|
username TEXT NOT NULL,
|
||||||
|
passhash TEXT NOT NULL,
|
||||||
|
created_at TEXT NOT NULL,
|
||||||
|
updated_at TEXT NOT NULL,
|
||||||
|
disabled BOOL
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS account_index01
|
||||||
|
ON account(id);
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS account_index02
|
||||||
|
ON account(username);
|
||||||
|
|
||||||
|
--- DROP TABLE IF EXISTS grant;
|
||||||
|
CREATE TABLE IF NOT EXISTS grant (
|
||||||
|
id TEXT NOT NULL,
|
||||||
|
account_id TEXT NOT NULL,
|
||||||
|
grantname TEXT NOT NULL,
|
||||||
|
created_at TEXT NOT NULL
|
||||||
|
);
|
||||||
|
CREATE INDEX IF NOT EXISTS grant_index01
|
||||||
|
ON grant(account_id);
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS grant_index02
|
||||||
|
ON grant(account_id, grantname);
|
||||||
|
`
|
||||||
@@ -221,7 +221,7 @@ func (oper *Operator) ListAccounts(ctx context.Context, accountID string, params
|
|||||||
}
|
}
|
||||||
for _, grantDescrs := range grantDescrs {
|
for _, grantDescrs := range grantDescrs {
|
||||||
grantShortDescrs := &mbctl.GrantShortDescr{
|
grantShortDescrs := &mbctl.GrantShortDescr{
|
||||||
Operation: grantDescrs.Operation,
|
Grantname: grantDescrs.Grantname,
|
||||||
CreatedAt: grantDescrs.CreatedAt,
|
CreatedAt: grantDescrs.CreatedAt,
|
||||||
}
|
}
|
||||||
accountShortDescr.Grants = append(accountShortDescr.Grants, grantShortDescrs)
|
accountShortDescr.Grants = append(accountShortDescr.Grants, grantShortDescrs)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func (oper *Operator) SeedAccount(ctx context.Context) (string, error) {
|
|||||||
for _, grantType := range grantTypes {
|
for _, grantType := range grantTypes {
|
||||||
grantDescr := &descr.Grant{
|
grantDescr := &descr.Grant{
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Operation: grantType,
|
Grantname: grantType,
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
}
|
}
|
||||||
err = oper.db.InsertGrant(ctx, grantDescr)
|
err = oper.db.InsertGrant(ctx, grantDescr)
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func (oper *Operator) RestoreDump(ctx context.Context, accountID string, params
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, grant := range dump.Grants {
|
for _, grant := range dump.Grants {
|
||||||
oper.log.Infof("Insert grant %s for account %d", grant.Operation, grant.AccountID)
|
oper.log.Infof("Insert grant %s for account %d", grant.Grantname, grant.AccountID)
|
||||||
err = oper.db.InsertGrant(ctx, &grant)
|
err = oper.db.InsertGrant(ctx, &grant)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
oper.log.Errorf("Insert account error: %v", err)
|
oper.log.Errorf("Insert account error: %v", err)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
|
|||||||
}
|
}
|
||||||
var grantOk bool
|
var grantOk bool
|
||||||
for _, grantType := range grantTypes {
|
for _, grantType := range grantTypes {
|
||||||
if grantType == params.Operation {
|
if grantType == params.Grantname {
|
||||||
grantOk = true
|
grantOk = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -60,12 +60,12 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Operation)
|
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Grantname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
if grantExists {
|
if grantExists {
|
||||||
err := fmt.Errorf("Grant %s for the user already exists", params.Operation)
|
err := fmt.Errorf("Grant %s for the user already exists", params.Grantname)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
now := time.Now().Format(time.RFC3339)
|
now := time.Now().Format(time.RFC3339)
|
||||||
@@ -73,7 +73,7 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
|
|||||||
ID: auxuuid.NewUUID(),
|
ID: auxuuid.NewUUID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
Operation: params.Operation,
|
Grantname: params.Grantname,
|
||||||
}
|
}
|
||||||
err = oper.db.InsertGrant(ctx, grantDescr)
|
err = oper.db.InsertGrant(ctx, grantDescr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -103,7 +103,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
|
|||||||
}
|
}
|
||||||
var grantOk bool
|
var grantOk bool
|
||||||
for _, grantType := range grantTypes {
|
for _, grantType := range grantTypes {
|
||||||
if grantType == params.Operation {
|
if grantType == params.Grantname {
|
||||||
grantOk = true
|
grantOk = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Operation)
|
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Grantname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
|
|||||||
err := fmt.Errorf("Requested grant for the user not found")
|
err := fmt.Errorf("Requested grant for the user not found")
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
err = oper.db.DeleteGrantByAccountID(ctx, accountDescr.ID, params.Operation)
|
err = oper.db.DeleteGrantByAccountID(ctx, accountDescr.ID, params.Grantname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
+79
-16
@@ -1,6 +1,7 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -37,6 +38,7 @@ type Server struct {
|
|||||||
x509key []byte
|
x509key []byte
|
||||||
state descr.Server
|
state descr.Server
|
||||||
sfile string
|
sfile string
|
||||||
|
logf *os.File
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer() (*Server, error) {
|
func NewServer() (*Server, error) {
|
||||||
@@ -117,26 +119,88 @@ func (srv *Server) Build() error {
|
|||||||
var err error
|
var err error
|
||||||
srv.log.Infof("Build server")
|
srv.log.Infof("Build server")
|
||||||
|
|
||||||
|
currUser, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("Error getting current user: %v\n", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cuid64, err := strconv.ParseInt(currUser.Uid, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cgid64, err := strconv.ParseInt(currUser.Gid, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
euid := int(cuid64)
|
||||||
|
egid := int(cgid64)
|
||||||
|
|
||||||
|
if cuid64 == 0 {
|
||||||
|
usr, err := user.Lookup(srv.conf.RunUser)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
uid64, err := strconv.ParseInt(usr.Uid, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
gid64, err := strconv.ParseInt(usr.Gid, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
euid = int(uid64)
|
||||||
|
egid = int(gid64)
|
||||||
|
}
|
||||||
|
|
||||||
// Mkdir log and data dir
|
// Mkdir log and data dir
|
||||||
srv.log.Infof("Create %s dir", srv.conf.DataDir)
|
datadir := srv.conf.DataDir
|
||||||
|
srv.log.Infof("Create %s dir", datadir)
|
||||||
err = os.MkdirAll(srv.conf.DataDir, 0750)
|
err = os.MkdirAll(srv.conf.DataDir, 0750)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if srv.conf.Daemon {
|
err = os.Chown(datadir, euid, egid)
|
||||||
logDir := filepath.Dir(srv.conf.LogPath)
|
if err != nil {
|
||||||
srv.log.Infof("Create %s dir", logDir)
|
return err
|
||||||
err = os.MkdirAll(logDir, 0750)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
runDir := filepath.Dir(srv.conf.RunPath)
|
|
||||||
srv.log.Infof("Create %s dir", runDir)
|
|
||||||
err = os.MkdirAll(runDir, 0750)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if srv.conf.AsDaemon {
|
||||||
|
logdir := filepath.Dir(srv.conf.LogPath)
|
||||||
|
//srv.logg.Infof("Creating log directory %s", logdir)
|
||||||
|
err = os.MkdirAll(logdir, 0750)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = os.Chown(logdir, euid, egid)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rundir := filepath.Dir(srv.conf.RunPath)
|
||||||
|
//srv.logg.Infof("Creating run directory %s", rundir)
|
||||||
|
err = os.MkdirAll(rundir, 0750)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = os.Chown(rundir, euid, egid)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Redirect stderr and stout
|
||||||
|
logFile, err := os.OpenFile(srv.conf.LogPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0640)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = syscall.Dup2(int(logFile.Fd()), int(os.Stdout.Fd()))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = syscall.Dup2(int(logFile.Fd()), int(os.Stderr.Fd()))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
srv.logf = logFile
|
||||||
|
}
|
||||||
|
|
||||||
// Create X509 certs
|
// Create X509 certs
|
||||||
srv.x509cert, srv.x509key, err = aux509.CreateX509SelfSignedCert(srv.conf.Hostname)
|
srv.x509cert, srv.x509key, err = aux509.CreateX509SelfSignedCert(srv.conf.Hostname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -305,13 +369,12 @@ func (srv *Server) PseudoFork() error {
|
|||||||
|
|
||||||
func (srv *Server) Daemonize() error {
|
func (srv *Server) Daemonize() error {
|
||||||
var err error
|
var err error
|
||||||
if srv.conf.Daemon {
|
if srv.conf.AsDaemon {
|
||||||
// Restart process process
|
// Restart process process
|
||||||
err = srv.PseudoFork()
|
err = srv.PseudoFork()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect stdin
|
// Redirect stdin
|
||||||
nullFile, err := os.OpenFile("/dev/null", os.O_RDWR, 0)
|
nullFile, err := os.OpenFile("/dev/null", os.O_RDWR, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ import (
|
|||||||
|
|
||||||
func (util *Util) DeleteGrant(cmd *cobra.Command, args []string) {
|
func (util *Util) DeleteGrant(cmd *cobra.Command, args []string) {
|
||||||
util.deleteGrantParams.Username = args[0]
|
util.deleteGrantParams.Username = args[0]
|
||||||
util.deleteGrantParams.Operation = args[1]
|
util.deleteGrantParams.Grantname = args[1]
|
||||||
res, err := util.deleteGrant(&util.deleteGrantParams)
|
res, err := util.deleteGrant(&util.deleteGrantParams)
|
||||||
printResponse(res, err)
|
printResponse(res, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteGrantParams struct {
|
type DeleteGrantParams struct {
|
||||||
Username string
|
Username string
|
||||||
Operation string
|
Grantname string
|
||||||
}
|
}
|
||||||
type DeleteGrantResult struct{}
|
type DeleteGrantResult struct{}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func (util *Util) deleteGrant(params *DeleteGrantParams) (*DeleteGrantResult, er
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
operParams := &mbctl.DeleteGrantParams{
|
operParams := &mbctl.DeleteGrantParams{
|
||||||
Username: params.Username,
|
Username: params.Username,
|
||||||
Operation: params.Operation,
|
Grantname: params.Grantname,
|
||||||
}
|
}
|
||||||
_, err = util.oper.DeleteGrant(ctx, util.operID, operParams)
|
_, err = util.oper.DeleteGrant(ctx, util.operID, operParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ import (
|
|||||||
|
|
||||||
func (util *Util) SetGrant(cmd *cobra.Command, args []string) {
|
func (util *Util) SetGrant(cmd *cobra.Command, args []string) {
|
||||||
util.setGrantParams.Username = args[0]
|
util.setGrantParams.Username = args[0]
|
||||||
util.setGrantParams.Operation = args[1]
|
util.setGrantParams.Grantname = args[1]
|
||||||
res, err := util.setGrant(&util.setGrantParams)
|
res, err := util.setGrant(&util.setGrantParams)
|
||||||
printResponse(res, err)
|
printResponse(res, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetGrantParams struct {
|
type SetGrantParams struct {
|
||||||
Username string
|
Username string
|
||||||
Operation string
|
Grantname string
|
||||||
}
|
}
|
||||||
type SetGrantResult struct {
|
type SetGrantResult struct {
|
||||||
GrantID string `json:"grantId"`
|
GrantID string `json:"grantId"`
|
||||||
@@ -32,7 +32,7 @@ func (util *Util) setGrant(params *SetGrantParams) (*SetGrantResult, error) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
operParams := &mbctl.SetGrantParams{
|
operParams := &mbctl.SetGrantParams{
|
||||||
Username: params.Username,
|
Username: params.Username,
|
||||||
Operation: params.Operation,
|
Grantname: params.Grantname,
|
||||||
}
|
}
|
||||||
operRes, err := util.oper.SetGrant(ctx, util.operID, operParams)
|
operRes, err := util.oper.SetGrant(ctx, util.operID, operParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCert(t *testing.T) {
|
||||||
|
var err error
|
||||||
|
util := NewUtil()
|
||||||
|
|
||||||
|
err = util.Build()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
args := []string{"seed"}
|
||||||
|
err = util.Exec(args)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
||||||
*/
|
|
||||||
package account
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (util *Util) CreateGrant(cmd *cobra.Command, args []string) {
|
|
||||||
//util.createGrantParams.Filename = args[0]
|
|
||||||
res, err := util.createGrant(util.createGrantParams)
|
|
||||||
printResponse(res, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
type createGrantParams struct{}
|
|
||||||
type createGrantResult struct{}
|
|
||||||
|
|
||||||
func (util *Util) createGrant(params createGrantParams) (createGrantResult, error) {
|
|
||||||
var err error
|
|
||||||
res := createGrantResult{}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||||
*/
|
*/
|
||||||
package account
|
package grant
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||||
*/
|
*/
|
||||||
package account
|
package grant
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||||
|
*/
|
||||||
|
package grant
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"mbase/pkg/client"
|
||||||
|
"mbase/pkg/mbctl"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (util *Util) SetGrant(cmd *cobra.Command, args []string) {
|
||||||
|
util.setGrantParams.Username = args[0]
|
||||||
|
util.setGrantParams.Grantname = args[1]
|
||||||
|
res, err := util.setGrant(util.setGrantParams)
|
||||||
|
printResponse(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetGrantParams struct {
|
||||||
|
Username string
|
||||||
|
Grantname string
|
||||||
|
}
|
||||||
|
type SetGrantResult struct {
|
||||||
|
GrantID string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (util *Util) setGrant(params SetGrantParams) (SetGrantResult, error) {
|
||||||
|
var err error
|
||||||
|
res := SetGrantResult{}
|
||||||
|
|
||||||
|
grpcConn, cli, err := client.NewClient(&util.access)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
defer grpcConn.Close()
|
||||||
|
operParams := &mbctl.SetGrantParams{
|
||||||
|
Username: params.Username,
|
||||||
|
Grantname: params.Grantname,
|
||||||
|
}
|
||||||
|
ctx := context.Background()
|
||||||
|
operRes, err := cli.SetGrant(ctx, operParams)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
res.GrantID = operRes.GrantID
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -4,13 +4,24 @@
|
|||||||
package grant
|
package grant
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"mbase/pkg/client"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CommonParams struct {
|
||||||
|
Hostname string
|
||||||
|
Port uint32
|
||||||
|
Username string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
|
||||||
type Util struct {
|
type Util struct {
|
||||||
rootCmd *cobra.Command
|
rootCmd *cobra.Command
|
||||||
createGrantParams createGrantParams
|
setGrantParams SetGrantParams
|
||||||
deleteGrantParams deleteGrantParams
|
deleteGrantParams deleteGrantParams
|
||||||
|
commonParams CommonParams
|
||||||
|
access client.Access
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUtil() *Util {
|
func NewUtil() *Util {
|
||||||
@@ -29,13 +40,13 @@ func (util *Util) BuildCmds() *cobra.Command {
|
|||||||
}
|
}
|
||||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||||
|
|
||||||
var createGrantCmd = &cobra.Command{
|
var setGrantCmd = &cobra.Command{
|
||||||
Use: "create name|id password",
|
Use: "set name|id grant",
|
||||||
Short: "Create grant",
|
Short: "Set grant",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
Run: util.CreateGrant,
|
Run: util.SetGrant,
|
||||||
}
|
}
|
||||||
rootCmd.AddCommand(createGrantCmd)
|
rootCmd.AddCommand(setGrantCmd)
|
||||||
|
|
||||||
var deleteGrantCmd = &cobra.Command{
|
var deleteGrantCmd = &cobra.Command{
|
||||||
Use: "delete name|id grant",
|
Use: "delete name|id grant",
|
||||||
@@ -49,3 +60,11 @@ func (util *Util) BuildCmds() *cobra.Command {
|
|||||||
return util.rootCmd
|
return util.rootCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (util *Util) SetAccess(cmd *cobra.Command, args []string) {
|
||||||
|
util.access = client.Access{
|
||||||
|
Hostname: util.commonParams.Hostname,
|
||||||
|
Port: util.commonParams.Port,
|
||||||
|
Username: util.commonParams.Username,
|
||||||
|
Password: util.commonParams.Password,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func (util *Util) Build() error {
|
|||||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||||
|
|
||||||
var dumpDatabaseCmd = &cobra.Command{
|
var dumpDatabaseCmd = &cobra.Command{
|
||||||
Use: "dump [filename|-]",
|
Use: "dump filename|-",
|
||||||
Short: "Dump application database",
|
Short: "Dump application database",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: util.DumpDatabase,
|
Run: util.DumpDatabase,
|
||||||
@@ -43,7 +43,7 @@ func (util *Util) Build() error {
|
|||||||
rootCmd.AddCommand(dumpDatabaseCmd)
|
rootCmd.AddCommand(dumpDatabaseCmd)
|
||||||
|
|
||||||
var restoreDatabaseCmd = &cobra.Command{
|
var restoreDatabaseCmd = &cobra.Command{
|
||||||
Use: "restore [] [filename|-]",
|
Use: "restore filename|-",
|
||||||
Short: "Restore application database",
|
Short: "Restore application database",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: util.RestoreDatabase,
|
Run: util.RestoreDatabase,
|
||||||
|
|||||||
@@ -662,6 +662,7 @@ build_os
|
|||||||
build_vendor
|
build_vendor
|
||||||
build_cpu
|
build_cpu
|
||||||
build
|
build
|
||||||
|
FIND
|
||||||
XARGS
|
XARGS
|
||||||
CPIO
|
CPIO
|
||||||
PODMAN
|
PODMAN
|
||||||
@@ -3646,6 +3647,57 @@ fi
|
|||||||
test -n "$XARGS" && break
|
test -n "$XARGS" && break
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for ac_prog in find false
|
||||||
|
do
|
||||||
|
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||||
|
set dummy $ac_prog; ac_word=$2
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||||
|
printf %s "checking for $ac_word... " >&6; }
|
||||||
|
if test ${ac_cv_path_FIND+y}
|
||||||
|
then :
|
||||||
|
printf %s "(cached) " >&6
|
||||||
|
else case e in #(
|
||||||
|
e) case $FIND in
|
||||||
|
[\\/]* | ?:[\\/]*)
|
||||||
|
ac_cv_path_FIND="$FIND" # Let the user override the test with a path.
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||||
|
for as_dir in $PATH
|
||||||
|
do
|
||||||
|
IFS=$as_save_IFS
|
||||||
|
case $as_dir in #(((
|
||||||
|
'') as_dir=./ ;;
|
||||||
|
*/) ;;
|
||||||
|
*) as_dir=$as_dir/ ;;
|
||||||
|
esac
|
||||||
|
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||||
|
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
|
||||||
|
ac_cv_path_FIND="$as_dir$ac_word$ac_exec_ext"
|
||||||
|
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
|
||||||
|
break 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
IFS=$as_save_IFS
|
||||||
|
|
||||||
|
;;
|
||||||
|
esac ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
FIND=$ac_cv_path_FIND
|
||||||
|
if test -n "$FIND"; then
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FIND" >&5
|
||||||
|
printf "%s\n" "$FIND" >&6; }
|
||||||
|
else
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||||
|
printf "%s\n" "no" >&6; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
test -n "$FIND" && break
|
||||||
|
done
|
||||||
|
|
||||||
for ac_prog in protoc false
|
for ac_prog in protoc false
|
||||||
do
|
do
|
||||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ AC_PATH_PROGS([PROTOC],[protoc true])
|
|||||||
AC_PATH_PROGS([PODMAN],[podman true])
|
AC_PATH_PROGS([PODMAN],[podman true])
|
||||||
AC_PATH_PROGS([CPIO],[cpio false])
|
AC_PATH_PROGS([CPIO],[cpio false])
|
||||||
AC_PATH_PROGS([XARGS],[xargs false])
|
AC_PATH_PROGS([XARGS],[xargs false])
|
||||||
|
AC_PATH_PROGS([FIND],[find false])
|
||||||
AC_PATH_PROGS([PROTOC],[protoc false])
|
AC_PATH_PROGS([PROTOC],[protoc false])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCert(t *testing.T) {
|
func TestCert(t *testing.T) {
|
||||||
|
|
||||||
{
|
{
|
||||||
//caCert, caKey, err := CreateX509SelfSignedCert("test1")
|
caCert, caKey, err := CreateX509SelfSignedCert("test1")
|
||||||
//require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
//fmt.Println(string(caCert))
|
fmt.Println(string(caCert))
|
||||||
//fmt.Println(string(caKey))
|
fmt.Println(string(caKey))
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
caCert, caKey, err := CreateX509CACert("test1")
|
caCert, caKey, err := CreateX509CACert("test1")
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ type Account struct {
|
|||||||
type Grant struct {
|
type Grant struct {
|
||||||
ID string `json:"id" yaml:"id" db:"id"`
|
ID string `json:"id" yaml:"id" db:"id"`
|
||||||
AccountID string `json:"accountID" yaml:"accountID" db:"account_id"`
|
AccountID string `json:"accountID" yaml:"accountID" db:"account_id"`
|
||||||
Operation string `json:"operation" yaml:"operation" db:"operation"`
|
Grantname string `json:"grantname" yaml:"grantname" db:"grantname"`
|
||||||
CreatedAt string `json:"createdAt" yaml:"createdAt" db:"created_at"`
|
CreatedAt string `json:"createdAt" yaml:"createdAt" db:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -193,7 +193,7 @@ type SetGrantParams struct {
|
|||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
||||||
AccountID string `protobuf:"bytes,2,opt,name=accountID,proto3" json:"accountID,omitempty"`
|
AccountID string `protobuf:"bytes,2,opt,name=accountID,proto3" json:"accountID,omitempty"`
|
||||||
Operation string `protobuf:"bytes,3,opt,name=operation,proto3" json:"operation,omitempty"`
|
Grantname string `protobuf:"bytes,3,opt,name=grantname,proto3" json:"grantname,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@@ -242,9 +242,9 @@ func (x *SetGrantParams) GetAccountID() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SetGrantParams) GetOperation() string {
|
func (x *SetGrantParams) GetGrantname() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Operation
|
return x.Grantname
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ type DeleteGrantParams struct {
|
|||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
||||||
AccountID string `protobuf:"bytes,2,opt,name=accountID,proto3" json:"accountID,omitempty"`
|
AccountID string `protobuf:"bytes,2,opt,name=accountID,proto3" json:"accountID,omitempty"`
|
||||||
Operation string `protobuf:"bytes,3,opt,name=operation,proto3" json:"operation,omitempty"`
|
Grantname string `protobuf:"bytes,3,opt,name=grantname,proto3" json:"grantname,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@@ -346,9 +346,9 @@ func (x *DeleteGrantParams) GetAccountID() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DeleteGrantParams) GetOperation() string {
|
func (x *DeleteGrantParams) GetGrantname() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Operation
|
return x.Grantname
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -915,7 +915,7 @@ func (x *AccountShortDescr) GetGrants() []*GrantShortDescr {
|
|||||||
|
|
||||||
type GrantShortDescr struct {
|
type GrantShortDescr struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Operation string `protobuf:"bytes,1,opt,name=operation,proto3" json:"operation,omitempty"`
|
Grantname string `protobuf:"bytes,1,opt,name=grantname,proto3" json:"grantname,omitempty"`
|
||||||
CreatedAt string `protobuf:"bytes,2,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
|
CreatedAt string `protobuf:"bytes,2,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@@ -951,9 +951,9 @@ func (*GrantShortDescr) Descriptor() ([]byte, []int) {
|
|||||||
return file_mbctl_proto_rawDescGZIP(), []int{19}
|
return file_mbctl_proto_rawDescGZIP(), []int{19}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GrantShortDescr) GetOperation() string {
|
func (x *GrantShortDescr) GetGrantname() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Operation
|
return x.Grantname
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -1064,9 +1064,9 @@ var file_mbctl_proto_rawDesc = string([]byte{
|
|||||||
0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63,
|
0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63,
|
||||||
0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63,
|
0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63,
|
||||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61,
|
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x72, 0x61, 0x6e, 0x74,
|
||||||
0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72,
|
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, 0x61, 0x6e,
|
||||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2a, 0x0a, 0x0e, 0x73, 0x65, 0x74, 0x47, 0x72, 0x61, 0x6e,
|
0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x2a, 0x0a, 0x0e, 0x73, 0x65, 0x74, 0x47, 0x72, 0x61, 0x6e,
|
||||||
0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74,
|
0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74,
|
||||||
0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x49,
|
0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x49,
|
||||||
0x44, 0x22, 0x6b, 0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74,
|
0x44, 0x22, 0x6b, 0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74,
|
||||||
@@ -1074,8 +1074,8 @@ var file_mbctl_proto_rawDesc = string([]byte{
|
|||||||
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
|
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
|
||||||
0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x18,
|
0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x18,
|
||||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44,
|
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44,
|
||||||
0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20,
|
0x12, 0x1c, 0x0a, 0x09, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x13,
|
0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x13,
|
||||||
0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73,
|
0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73,
|
||||||
0x75, 0x6c, 0x74, 0x22, 0x4d, 0x0a, 0x13, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63,
|
0x75, 0x6c, 0x74, 0x22, 0x4d, 0x0a, 0x13, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63,
|
||||||
0x6f, 0x75, 0x6e, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73,
|
0x6f, 0x75, 0x6e, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73,
|
||||||
@@ -1127,8 +1127,8 @@ var file_mbctl_proto_rawDesc = string([]byte{
|
|||||||
0x6f, 0x6c, 0x2e, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x44, 0x65, 0x73,
|
0x6f, 0x6c, 0x2e, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x44, 0x65, 0x73,
|
||||||
0x63, 0x72, 0x52, 0x06, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x22, 0x4d, 0x0a, 0x0f, 0x67, 0x72,
|
0x63, 0x72, 0x52, 0x06, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x22, 0x4d, 0x0a, 0x0f, 0x67, 0x72,
|
||||||
0x61, 0x6e, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x44, 0x65, 0x73, 0x63, 0x72, 0x12, 0x1c, 0x0a,
|
0x61, 0x6e, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x44, 0x65, 0x73, 0x63, 0x72, 0x12, 0x1c, 0x0a,
|
||||||
0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
0x09, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x63,
|
0x52, 0x09, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63,
|
||||||
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||||
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x10, 0x0a, 0x0e, 0x67, 0x65, 0x74,
|
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x10, 0x0a, 0x0e, 0x67, 0x65, 0x74,
|
||||||
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x2a, 0x0a, 0x0e, 0x67,
|
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x2a, 0x0a, 0x0e, 0x67,
|
||||||
|
|||||||
+3
-3
@@ -35,7 +35,7 @@ message restoreDumpResult {
|
|||||||
message setGrantParams {
|
message setGrantParams {
|
||||||
string username = 1;
|
string username = 1;
|
||||||
string accountID = 2;
|
string accountID = 2;
|
||||||
string operation = 3;
|
string grantname = 3;
|
||||||
}
|
}
|
||||||
message setGrantResult {
|
message setGrantResult {
|
||||||
string grantID = 1;
|
string grantID = 1;
|
||||||
@@ -44,7 +44,7 @@ message setGrantResult {
|
|||||||
message deleteGrantParams {
|
message deleteGrantParams {
|
||||||
string username = 1;
|
string username = 1;
|
||||||
string accountID = 2;
|
string accountID = 2;
|
||||||
string operation = 3;
|
string grantname = 3;
|
||||||
}
|
}
|
||||||
message deleteGrantResult {}
|
message deleteGrantResult {}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ message accountShortDescr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message grantShortDescr {
|
message grantShortDescr {
|
||||||
string operation = 1;
|
string grantname = 1;
|
||||||
string createdAt = 2;
|
string createdAt = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user