Documentation ¶
Index ¶
- func InitDb(c common.Config) (*gorm.DB, error)
- func InsertGroup(db *gorm.DB, conf common.Config, group Group) error
- func InsertHost(db *gorm.DB, conf common.Config, host Host) error
- func InsertShadow(db *gorm.DB, conf common.Config, shadow Shadow, uid int32) error
- func InsertUser(db *gorm.DB, conf common.Config, user Password) error
- type Group
- type Host
- type Password
- type Shadow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsertGroup ¶
Insert group in database
func InsertHost ¶
Insert new host in database
func InsertShadow ¶
Insert new shadow in database If uid >= 0 it will be used otherwise shadow.Username will be used
Types ¶
type Group ¶
type Group struct { ID uint32 Groupname string `gorm:"unique" form:"groupname"` GroupPassword string `gorm:"default:'x'" form:"password"` GID int32 `gorm:"unique" form:"gid"` Users string `form:"-"` }
Represent group file
func GetGroup ¶
Gets group, group specified with either groupname or uid. If both are provided gid will be used, gid must be a negative value to not be used. Search will return groups starting with searched string. If search is provided with gid it will be ignored. If name is empty string, gid is negative and search is true then all groups are returned.
type Host ¶
type Host struct { ID uint32 IPv4 string `form:"ipv4"` IPv6 string `form:"ipv6"` Hostnames string `gorm:"not null" form:"hostnames"` }
Represent host file
func GetHost ¶
Gets host, specified with either hostname, ipv4 or ipv6. If more then one is provided hostname will be used. Search will return hosts starting with searched hostname. If search is provided with any other argument, it will be ignored. If name, ipv4 and ipv6 are empty string and search is true then all hosts are returned.
type Password ¶
type Password struct { ID uint32 Username string `gorm:"unique" form:"username"` Password string `gorm:"default:'x'" form:"-"` UID int32 `gorm:"unique" form:"uid"` GID int32 `form:"gid"` Gecos string `form:"gecos"` Home string `form:"home"` Shell string `form:"shell"` }
Represents the passwd file.
func GetUser ¶
Returns users with specified name. If user is empty string and uid is a negative value all users are returned. If uid is a positive value specified user is returned. If name and search is soecified all users starting with name is returned. If only name is specified user with exactly that name is returned.
type Shadow ¶
type Shadow struct { ID uint32 Username string `gorm:"unique" form:"username"` Password string `form:"password"` LastChange uint32 `form:"last_change"` MinPasswordAge uint32 `gorm:"default:0" form:"min_password_age"` MaxPasswordAge uint32 `gorm:"default:99999" form:"max_password_age"` WarningPeriod uint32 `gorm:"default:7" form:"warning_period"` InactivePeriod uint32 `form:"inactive_period"` ExpireDate string `form:"expire_date"` }
Represent shadow file
func GetShadow ¶
Gets shadow fields, specified with either username or uid. If both are provided uid will be used, uid must be a negative value to not be used. Search will return shadow fields starting with searched username. If search is provided with uid it will be ignored. If user is empty string, uid is negative and search is true then all shadow records are returned.