You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nickserv.go 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  1. // Copyright (c) 2017 Daniel Oaks <daniel@danieloaks.net>
  2. // released under the MIT license
  3. package irc
  4. import (
  5. "fmt"
  6. "regexp"
  7. "strconv"
  8. "strings"
  9. "time"
  10. "github.com/goshuirc/irc-go/ircfmt"
  11. "github.com/oragono/oragono/irc/modes"
  12. "github.com/oragono/oragono/irc/passwd"
  13. "github.com/oragono/oragono/irc/sno"
  14. "github.com/oragono/oragono/irc/utils"
  15. )
  16. // "enabled" callbacks for specific nickserv commands
  17. func servCmdRequiresAccreg(config *Config) bool {
  18. return config.Accounts.Registration.Enabled
  19. }
  20. func servCmdRequiresAuthEnabled(config *Config) bool {
  21. return config.Accounts.AuthenticationEnabled
  22. }
  23. func servCmdRequiresNickRes(config *Config) bool {
  24. return config.Accounts.AuthenticationEnabled && config.Accounts.NickReservation.Enabled
  25. }
  26. func servCmdRequiresBouncerEnabled(config *Config) bool {
  27. return config.Accounts.Multiclient.Enabled
  28. }
  29. const (
  30. nsPrefix = "NickServ!NickServ@localhost"
  31. )
  32. const nickservHelp = `NickServ lets you register, log in to, and manage an account.`
  33. var (
  34. nickservCommands = map[string]*serviceCommand{
  35. "drop": {
  36. handler: nsDropHandler,
  37. help: `Syntax: $bDROP [nickname]$b
  38. DROP de-links the given (or your current) nickname from your user account.`,
  39. helpShort: `$bDROP$b de-links your current (or the given) nickname from your user account.`,
  40. enabled: servCmdRequiresNickRes,
  41. authRequired: true,
  42. },
  43. "enforce": {
  44. hidden: true,
  45. handler: nsEnforceHandler,
  46. help: `Syntax: $bENFORCE [method]$b
  47. ENFORCE is an alias for $bGET enforce$b and $bSET enforce$b. See the help
  48. entry for $bSET$b for more information.`,
  49. authRequired: true,
  50. enabled: servCmdRequiresNickRes,
  51. },
  52. "ghost": {
  53. handler: nsGhostHandler,
  54. help: `Syntax: $bGHOST <nickname>$b
  55. GHOST disconnects the given user from the network if they're logged in with the
  56. same user account, letting you reclaim your nickname.`,
  57. helpShort: `$bGHOST$b reclaims your nickname.`,
  58. enabled: servCmdRequiresNickRes,
  59. authRequired: true,
  60. minParams: 1,
  61. },
  62. "group": {
  63. handler: nsGroupHandler,
  64. help: `Syntax: $bGROUP$b
  65. GROUP links your current nickname with your logged-in account, so other people
  66. will not be able to use it.`,
  67. helpShort: `$bGROUP$b links your current nickname to your user account.`,
  68. enabled: servCmdRequiresNickRes,
  69. authRequired: true,
  70. },
  71. "identify": {
  72. handler: nsIdentifyHandler,
  73. help: `Syntax: $bIDENTIFY <username> [password]$b
  74. IDENTIFY lets you login to the given username using either password auth, or
  75. certfp (your client certificate) if a password is not given.`,
  76. helpShort: `$bIDENTIFY$b lets you login to your account.`,
  77. enabled: servCmdRequiresAuthEnabled,
  78. minParams: 1,
  79. },
  80. "list": {
  81. handler: nsListHandler,
  82. help: `Syntax: $bLIST [regex]$b
  83. LIST returns the list of registered nicknames, which match the given regex.
  84. If no regex is provided, all registered nicknames are returned.`,
  85. helpShort: `$bLIST$b searches the list of registered nicknames.`,
  86. enabled: servCmdRequiresAuthEnabled,
  87. capabs: []string{"accreg"},
  88. minParams: 0,
  89. },
  90. "info": {
  91. handler: nsInfoHandler,
  92. help: `Syntax: $bINFO [username]$b
  93. INFO gives you information about the given (or your own) user account.`,
  94. helpShort: `$bINFO$b gives you information on a user account.`,
  95. },
  96. "register": {
  97. handler: nsRegisterHandler,
  98. // TODO: "email" is an oversimplification here; it's actually any callback, e.g.,
  99. // person@example.com, mailto:person@example.com, tel:16505551234.
  100. help: `Syntax: $bREGISTER <password> [email]$b
  101. REGISTER lets you register your current nickname as a user account. If the
  102. server allows anonymous registration, you can omit the e-mail address.
  103. If you are currently logged in with a TLS client certificate and wish to use
  104. it instead of a password to log in, send * as the password.`,
  105. helpShort: `$bREGISTER$b lets you register a user account.`,
  106. enabled: servCmdRequiresAccreg,
  107. minParams: 1,
  108. maxParams: 2,
  109. },
  110. "sadrop": {
  111. handler: nsDropHandler,
  112. help: `Syntax: $bSADROP <nickname>$b
  113. SADROP forcibly de-links the given nickname from the attached user account.`,
  114. helpShort: `$bSADROP$b forcibly de-links the given nickname from its user account.`,
  115. capabs: []string{"accreg"},
  116. enabled: servCmdRequiresNickRes,
  117. minParams: 1,
  118. },
  119. "saregister": {
  120. handler: nsSaregisterHandler,
  121. help: `Syntax: $bSAREGISTER <username> [password]$b
  122. SAREGISTER registers an account on someone else's behalf.
  123. This is for use in configurations that require SASL for all connections;
  124. an administrator can set use this command to set up user accounts.`,
  125. helpShort: `$bSAREGISTER$b registers an account on someone else's behalf.`,
  126. enabled: servCmdRequiresAuthEnabled,
  127. capabs: []string{"accreg"},
  128. minParams: 1,
  129. },
  130. "sessions": {
  131. handler: nsSessionsHandler,
  132. help: `Syntax: $bSESSIONS [nickname]$b
  133. SESSIONS lists information about the sessions currently attached, via
  134. the server's multiclient functionality, to your nickname. An administrator
  135. can use this command to list another user's sessions.`,
  136. helpShort: `$bSESSIONS$b lists the sessions attached to a nickname.`,
  137. enabled: servCmdRequiresBouncerEnabled,
  138. },
  139. "unregister": {
  140. handler: nsUnregisterHandler,
  141. help: `Syntax: $bUNREGISTER <username> [code]$b
  142. UNREGISTER lets you delete your user account (or someone else's, if you're an
  143. IRC operator with the correct permissions). To prevent accidental
  144. unregistrations, a verification code is required; invoking the command without
  145. a code will display the necessary code.`,
  146. helpShort: `$bUNREGISTER$b lets you delete your user account.`,
  147. enabled: servCmdRequiresAuthEnabled,
  148. minParams: 1,
  149. },
  150. "erase": {
  151. handler: nsUnregisterHandler,
  152. help: `Syntax: $bERASE <username> [code]$b
  153. ERASE deletes all records of an account, allowing it to be re-registered.
  154. This should be used with caution, because it violates an expectation that
  155. account names are permanent identifiers. Typically, UNREGISTER should be
  156. used instead. A confirmation code is required; invoking the command
  157. without a code will display the necessary code.`,
  158. helpShort: `$bERASE$b erases all records of an account, allowing reuse.`,
  159. enabled: servCmdRequiresAuthEnabled,
  160. capabs: []string{"accreg"},
  161. minParams: 1,
  162. },
  163. "verify": {
  164. handler: nsVerifyHandler,
  165. help: `Syntax: $bVERIFY <username> <code>$b
  166. VERIFY lets you complete an account registration, if the server requires email
  167. or other verification.`,
  168. helpShort: `$bVERIFY$b lets you complete account registration.`,
  169. enabled: servCmdRequiresAccreg,
  170. minParams: 2,
  171. },
  172. "passwd": {
  173. handler: nsPasswdHandler,
  174. help: `Syntax: $bPASSWD <current> <new> <new_again>$b
  175. Or: $bPASSWD <username> <new>$b
  176. PASSWD lets you change your account password. You must supply your current
  177. password and confirm the new one by typing it twice. If you're an IRC operator
  178. with the correct permissions, you can use PASSWD to reset someone else's
  179. password by supplying their username and then the desired password. To
  180. indicate an empty password, use * instead.`,
  181. helpShort: `$bPASSWD$b lets you change your password.`,
  182. enabled: servCmdRequiresAuthEnabled,
  183. minParams: 2,
  184. },
  185. "get": {
  186. handler: nsGetHandler,
  187. help: `Syntax: $bGET <setting>$b
  188. GET queries the current values of your account settings. For more information
  189. on the settings and their possible values, see HELP SET.`,
  190. helpShort: `$bGET$b queries the current values of your account settings`,
  191. authRequired: true,
  192. enabled: servCmdRequiresAuthEnabled,
  193. minParams: 1,
  194. },
  195. "saget": {
  196. handler: nsGetHandler,
  197. help: `Syntax: $bSAGET <account> <setting>$b
  198. SAGET queries the values of someone else's account settings. For more
  199. information on the settings and their possible values, see HELP SET.`,
  200. helpShort: `$bSAGET$b queries the current values of another user's account settings`,
  201. enabled: servCmdRequiresAuthEnabled,
  202. minParams: 2,
  203. capabs: []string{"accreg"},
  204. },
  205. "set": {
  206. handler: nsSetHandler,
  207. helpShort: `$bSET$b modifies your account settings`,
  208. // these are broken out as separate strings so they can be translated separately
  209. helpStrings: []string{
  210. `Syntax $bSET <setting> <value>$b
  211. SET modifies your account settings. The following settings are available:`,
  212. `$bENFORCE$b
  213. 'enforce' lets you specify a custom enforcement mechanism for your registered
  214. nicknames. Your options are:
  215. 1. 'none' [no enforcement, overriding the server default]
  216. or else they will be renamed]
  217. 2. 'strict' [you must already be authenticated to use the nick]
  218. 3. 'default' [use the server default]`,
  219. `$bMULTICLIENT$b
  220. If 'multiclient' is enabled and you are already logged in and using a nick, a
  221. second client of yours that authenticates with SASL and requests the same nick
  222. is allowed to attach to the nick as well (this is comparable to the behavior
  223. of IRC "bouncers" like ZNC). Your options are 'on' (allow this behavior),
  224. 'off' (disallow it), and 'default' (use the server default value).`,
  225. `$bAUTOREPLAY-LINES$b
  226. 'autoreplay-lines' controls the number of lines of channel history that will
  227. be replayed to you automatically when joining a channel. Your options are any
  228. positive number, 0 to disable the feature, and 'default' to use the server
  229. default.`,
  230. `$bREPLAY-JOINS$b
  231. 'replay-joins' controls whether replayed channel history will include
  232. lines for join and part. This provides more information about the context of
  233. messages, but may be spammy. Your options are 'always', 'never', and the default
  234. of 'commands-only' (the messages will be replayed in /HISTORY output, but not
  235. during autoreplay).`,
  236. `$bALWAYS-ON$b
  237. 'always-on' controls whether your nickname/identity will remain active
  238. even while you are disconnected from the server. Your options are 'true',
  239. 'false', and 'default' (use the server default value).`,
  240. `$bAUTOREPLAY-MISSED$b
  241. 'autoreplay-missed' is only effective for always-on clients. If enabled,
  242. if you have at most one active session, the server will remember the time
  243. you disconnect and then replay missed messages to you when you reconnect.
  244. Your options are 'on' and 'off'.`,
  245. `$bDM-HISTORY$b
  246. 'dm-history' is only effective for always-on clients. It lets you control
  247. how the history of your direct messages is stored. Your options are:
  248. 1. 'off' [no history]
  249. 2. 'ephemeral' [a limited amount of temporary history, not stored on disk]
  250. 3. 'on' [history stored in a permanent database, if available]
  251. 4. 'default' [use the server default]`,
  252. `$bAUTO-AWAY$b
  253. 'auto-away' is only effective for always-on clients. If enabled, you will
  254. automatically be marked away when all your sessions are disconnected, and
  255. automatically return from away when you connect again.`,
  256. },
  257. authRequired: true,
  258. enabled: servCmdRequiresAuthEnabled,
  259. minParams: 2,
  260. },
  261. "saset": {
  262. handler: nsSetHandler,
  263. help: `Syntax: $bSASET <account> <setting> <value>$b
  264. SASET modifies the values of someone else's account settings. For more
  265. information on the settings and their possible values, see HELP SET.`,
  266. helpShort: `$bSASET$b modifies another user's account settings`,
  267. enabled: servCmdRequiresAuthEnabled,
  268. minParams: 3,
  269. capabs: []string{"accreg"},
  270. },
  271. "cert": {
  272. handler: nsCertHandler,
  273. help: `Syntax: $bCERT <LIST | ADD | DEL> [account] [certfp]$b
  274. CERT examines or modifies the TLS certificate fingerprints that can be used to
  275. log into an account. Specifically, $bCERT LIST$b lists the authorized
  276. fingerprints, $bCERT ADD <fingerprint>$b adds a new fingerprint, and
  277. $bCERT DEL <fingerprint>$b removes a fingerprint. If you're an IRC operator
  278. with the correct permissions, you can act on another user's account, for
  279. example with $bCERT ADD <account> <fingerprint>$b.`,
  280. helpShort: `$bCERT$b controls a user account's certificate fingerprints`,
  281. enabled: servCmdRequiresAuthEnabled,
  282. minParams: 1,
  283. },
  284. }
  285. )
  286. // nsNotice sends the client a notice from NickServ
  287. func nsNotice(rb *ResponseBuffer, text string) {
  288. // XXX i can't figure out how to use OragonoServices[servicename].prefix here
  289. // without creating a compile-time initialization loop
  290. rb.Add(nil, nsPrefix, "NOTICE", rb.target.Nick(), text)
  291. }
  292. func nsGetHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  293. var account string
  294. if command == "saget" {
  295. account = params[0]
  296. params = params[1:]
  297. } else {
  298. account = client.Account()
  299. }
  300. accountData, err := server.accounts.LoadAccount(account)
  301. if err == errAccountDoesNotExist {
  302. nsNotice(rb, client.t("No such account"))
  303. return
  304. } else if err != nil {
  305. nsNotice(rb, client.t("Error loading account data"))
  306. return
  307. }
  308. displaySetting(params[0], accountData.Settings, client, rb)
  309. }
  310. func displaySetting(settingName string, settings AccountSettings, client *Client, rb *ResponseBuffer) {
  311. config := client.server.Config()
  312. switch strings.ToLower(settingName) {
  313. case "enforce":
  314. storedValue := settings.NickEnforcement
  315. serializedStoredValue := nickReservationToString(storedValue)
  316. nsNotice(rb, fmt.Sprintf(client.t("Your stored nickname enforcement setting is: %s"), serializedStoredValue))
  317. serializedActualValue := nickReservationToString(configuredEnforcementMethod(config, storedValue))
  318. nsNotice(rb, fmt.Sprintf(client.t("Given current server settings, your nickname is enforced with: %s"), serializedActualValue))
  319. case "autoreplay-lines":
  320. if settings.AutoreplayLines == nil {
  321. nsNotice(rb, fmt.Sprintf(client.t("You will receive the server default of %d lines of autoreplayed history"), config.History.AutoreplayOnJoin))
  322. } else {
  323. nsNotice(rb, fmt.Sprintf(client.t("You will receive %d lines of autoreplayed history"), *settings.AutoreplayLines))
  324. }
  325. case "replay-joins":
  326. switch settings.ReplayJoins {
  327. case ReplayJoinsCommandsOnly:
  328. nsNotice(rb, client.t("You will see JOINs and PARTs in /HISTORY output, but not in autoreplay"))
  329. case ReplayJoinsAlways:
  330. nsNotice(rb, client.t("You will see JOINs and PARTs in /HISTORY output and in autoreplay"))
  331. case ReplayJoinsNever:
  332. nsNotice(rb, client.t("You will not see JOINs and PARTs in /HISTORY output or in autoreplay"))
  333. }
  334. case "multiclient":
  335. if !config.Accounts.Multiclient.Enabled {
  336. nsNotice(rb, client.t("This feature has been disabled by the server administrators"))
  337. } else {
  338. switch settings.AllowBouncer {
  339. case MulticlientAllowedServerDefault:
  340. if config.Accounts.Multiclient.AllowedByDefault {
  341. nsNotice(rb, client.t("Multiclient functionality is currently enabled for your account, but you can opt out"))
  342. } else {
  343. nsNotice(rb, client.t("Multiclient functionality is currently disabled for your account, but you can opt in"))
  344. }
  345. case MulticlientDisallowedByUser:
  346. nsNotice(rb, client.t("Multiclient functionality is currently disabled for your account"))
  347. case MulticlientAllowedByUser:
  348. nsNotice(rb, client.t("Multiclient functionality is currently enabled for your account"))
  349. }
  350. }
  351. case "always-on":
  352. stored := settings.AlwaysOn
  353. actual := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, stored)
  354. nsNotice(rb, fmt.Sprintf(client.t("Your stored always-on setting is: %s"), persistentStatusToString(stored)))
  355. if actual {
  356. nsNotice(rb, client.t("Given current server settings, your client is always-on"))
  357. } else {
  358. nsNotice(rb, client.t("Given current server settings, your client is not always-on"))
  359. }
  360. case "autoreplay-missed":
  361. stored := settings.AutoreplayMissed
  362. if stored {
  363. alwaysOn := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, settings.AlwaysOn)
  364. if alwaysOn {
  365. nsNotice(rb, client.t("Autoreplay of missed messages is enabled"))
  366. } else {
  367. nsNotice(rb, client.t("You have enabled autoreplay of missed messages, but you can't receive them because your client isn't set to always-on"))
  368. }
  369. } else {
  370. nsNotice(rb, client.t("Your account is not configured to receive autoreplayed missed messages"))
  371. }
  372. case "auto-away":
  373. stored := settings.AutoAway
  374. alwaysOn := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, settings.AlwaysOn)
  375. actual := persistenceEnabled(config.Accounts.Multiclient.AutoAway, settings.AutoAway)
  376. nsNotice(rb, fmt.Sprintf(client.t("Your stored auto-away setting is: %s"), persistentStatusToString(stored)))
  377. if actual && alwaysOn {
  378. nsNotice(rb, client.t("Given current server settings, auto-away is enabled for your client"))
  379. } else if actual && !alwaysOn {
  380. nsNotice(rb, client.t("Because your client is not always-on, auto-away is disabled"))
  381. } else if !actual {
  382. nsNotice(rb, client.t("Given current server settings, auto-away is disabled for your client"))
  383. }
  384. case "dm-history":
  385. effectiveValue := historyEnabled(config.History.Persistent.DirectMessages, settings.DMHistory)
  386. csNotice(rb, fmt.Sprintf(client.t("Your stored direct message history setting is: %s"), historyStatusToString(settings.DMHistory)))
  387. csNotice(rb, fmt.Sprintf(client.t("Given current server settings, your direct message history setting is: %s"), historyStatusToString(effectiveValue)))
  388. default:
  389. nsNotice(rb, client.t("No such setting"))
  390. }
  391. }
  392. func nsSetHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  393. var account string
  394. if command == "saset" {
  395. account = params[0]
  396. params = params[1:]
  397. } else {
  398. account = client.Account()
  399. }
  400. var munger settingsMunger
  401. var finalSettings AccountSettings
  402. var err error
  403. switch strings.ToLower(params[0]) {
  404. case "pass":
  405. nsNotice(rb, client.t("To change a password, use the PASSWD command. For details, /msg NickServ HELP PASSWD"))
  406. return
  407. case "enforce":
  408. var method NickEnforcementMethod
  409. method, err = nickReservationFromString(params[1])
  410. if err != nil {
  411. err = errInvalidParams
  412. break
  413. }
  414. // updating enforcement settings is special-cased, because it requires
  415. // an update to server.accounts.accountToMethod
  416. finalSettings, err = server.accounts.SetEnforcementStatus(account, method)
  417. if err == nil {
  418. finalSettings.NickEnforcement = method // success
  419. }
  420. case "autoreplay-lines":
  421. var newValue *int
  422. if strings.ToLower(params[1]) != "default" {
  423. val, err_ := strconv.Atoi(params[1])
  424. if err_ != nil || val < 0 {
  425. err = errInvalidParams
  426. break
  427. }
  428. newValue = new(int)
  429. *newValue = val
  430. }
  431. munger = func(in AccountSettings) (out AccountSettings, err error) {
  432. out = in
  433. out.AutoreplayLines = newValue
  434. return
  435. }
  436. case "multiclient":
  437. var newValue MulticlientAllowedSetting
  438. if strings.ToLower(params[1]) == "default" {
  439. newValue = MulticlientAllowedServerDefault
  440. } else {
  441. var enabled bool
  442. enabled, err = utils.StringToBool(params[1])
  443. if enabled {
  444. newValue = MulticlientAllowedByUser
  445. } else {
  446. newValue = MulticlientDisallowedByUser
  447. }
  448. }
  449. if err == nil {
  450. munger = func(in AccountSettings) (out AccountSettings, err error) {
  451. out = in
  452. out.AllowBouncer = newValue
  453. return
  454. }
  455. }
  456. case "replay-joins":
  457. var newValue ReplayJoinsSetting
  458. newValue, err = replayJoinsSettingFromString(params[1])
  459. if err == nil {
  460. munger = func(in AccountSettings) (out AccountSettings, err error) {
  461. out = in
  462. out.ReplayJoins = newValue
  463. return
  464. }
  465. }
  466. case "always-on":
  467. // #821: it's problematic to alter the value of always-on if you're not
  468. // the (actual or potential) always-on client yourself. make an exception
  469. // for `saset` to give operators an escape hatch (any consistency problems
  470. // can probably be fixed by restarting the server):
  471. if command != "saset" {
  472. details := client.Details()
  473. if details.nick != details.accountName {
  474. err = errNickAccountMismatch
  475. }
  476. }
  477. if err == nil {
  478. var newValue PersistentStatus
  479. newValue, err = persistentStatusFromString(params[1])
  480. // "opt-in" and "opt-out" don't make sense as user preferences
  481. if err == nil && newValue != PersistentOptIn && newValue != PersistentOptOut {
  482. munger = func(in AccountSettings) (out AccountSettings, err error) {
  483. out = in
  484. out.AlwaysOn = newValue
  485. return
  486. }
  487. }
  488. }
  489. case "autoreplay-missed":
  490. var newValue bool
  491. newValue, err = utils.StringToBool(params[1])
  492. if err == nil {
  493. munger = func(in AccountSettings) (out AccountSettings, err error) {
  494. out = in
  495. out.AutoreplayMissed = newValue
  496. return
  497. }
  498. }
  499. case "auto-away":
  500. var newValue PersistentStatus
  501. newValue, err = persistentStatusFromString(params[1])
  502. // "opt-in" and "opt-out" don't make sense as user preferences
  503. if err == nil && newValue != PersistentOptIn && newValue != PersistentOptOut {
  504. munger = func(in AccountSettings) (out AccountSettings, err error) {
  505. out = in
  506. out.AutoAway = newValue
  507. return
  508. }
  509. }
  510. case "dm-history":
  511. var newValue HistoryStatus
  512. newValue, err = historyStatusFromString(params[1])
  513. if err == nil {
  514. munger = func(in AccountSettings) (out AccountSettings, err error) {
  515. out = in
  516. out.DMHistory = newValue
  517. return
  518. }
  519. }
  520. default:
  521. err = errInvalidParams
  522. }
  523. if munger != nil {
  524. finalSettings, err = server.accounts.ModifyAccountSettings(account, munger)
  525. }
  526. switch err {
  527. case nil:
  528. nsNotice(rb, client.t("Successfully changed your account settings"))
  529. displaySetting(params[0], finalSettings, client, rb)
  530. case errInvalidParams, errAccountDoesNotExist, errFeatureDisabled, errAccountUnverified, errAccountUpdateFailed:
  531. nsNotice(rb, client.t(err.Error()))
  532. case errNickAccountMismatch:
  533. nsNotice(rb, fmt.Sprintf(client.t("Your nickname must match your account name %s exactly to modify this setting. Try changing it with /NICK, or logging out and back in with the correct nickname."), client.AccountName()))
  534. default:
  535. // unknown error
  536. nsNotice(rb, client.t("An error occurred"))
  537. }
  538. }
  539. func nsDropHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  540. sadrop := command == "sadrop"
  541. var nick string
  542. if len(params) > 0 {
  543. nick = params[0]
  544. } else {
  545. nick = client.NickCasefolded()
  546. }
  547. err := server.accounts.SetNickReserved(client, nick, sadrop, false)
  548. if err == nil {
  549. nsNotice(rb, fmt.Sprintf(client.t("Successfully ungrouped nick %s with your account"), nick))
  550. } else if err == errAccountNotLoggedIn {
  551. nsNotice(rb, client.t("You're not logged into an account"))
  552. } else if err == errAccountCantDropPrimaryNick {
  553. nsNotice(rb, client.t("You can't ungroup your primary nickname (try unregistering your account instead)"))
  554. } else {
  555. nsNotice(rb, client.t("Could not ungroup nick"))
  556. }
  557. }
  558. func nsGhostHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  559. nick := params[0]
  560. ghost := server.clients.Get(nick)
  561. if ghost == nil {
  562. nsNotice(rb, client.t("No such nick"))
  563. return
  564. } else if ghost == client {
  565. nsNotice(rb, client.t("You can't GHOST yourself (try /QUIT instead)"))
  566. return
  567. } else if ghost.AlwaysOn() {
  568. nsNotice(rb, client.t("You can't GHOST an always-on client"))
  569. return
  570. }
  571. authorized := false
  572. account := client.Account()
  573. if account != "" {
  574. // the user must either own the nick, or the target client
  575. authorized = (server.accounts.NickToAccount(nick) == account) || (ghost.Account() == account)
  576. }
  577. if !authorized {
  578. nsNotice(rb, client.t("You don't own that nick"))
  579. return
  580. }
  581. ghost.Quit(fmt.Sprintf(ghost.t("GHOSTed by %s"), client.Nick()), nil)
  582. ghost.destroy(nil)
  583. }
  584. func nsGroupHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  585. nick := client.Nick()
  586. err := server.accounts.SetNickReserved(client, nick, false, true)
  587. if err == nil {
  588. nsNotice(rb, fmt.Sprintf(client.t("Successfully grouped nick %s with your account"), nick))
  589. } else if err == errAccountTooManyNicks {
  590. nsNotice(rb, client.t("You have too many nicks reserved already (you can remove some with /NS DROP)"))
  591. } else if err == errNicknameReserved {
  592. nsNotice(rb, client.t("That nickname is already reserved by someone else"))
  593. } else {
  594. nsNotice(rb, client.t("Error reserving nickname"))
  595. }
  596. }
  597. func nsLoginThrottleCheck(client *Client, rb *ResponseBuffer) (success bool) {
  598. throttled, remainingTime := client.checkLoginThrottle()
  599. if throttled {
  600. nsNotice(rb, fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime))
  601. }
  602. return !throttled
  603. }
  604. func nsIdentifyHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  605. if client.LoggedIntoAccount() {
  606. nsNotice(rb, client.t("You're already logged into an account"))
  607. return
  608. }
  609. var err error
  610. loginSuccessful := false
  611. var username, passphrase string
  612. if len(params) == 1 {
  613. if rb.session.certfp != "" {
  614. username = params[0]
  615. } else {
  616. // XXX undocumented compatibility mode with other nickservs, allowing
  617. // /msg NickServ identify passphrase
  618. username = client.NickCasefolded()
  619. passphrase = params[0]
  620. }
  621. } else {
  622. username = params[0]
  623. passphrase = params[1]
  624. }
  625. // try passphrase
  626. if passphrase != "" {
  627. err = server.accounts.AuthenticateByPassphrase(client, username, passphrase)
  628. loginSuccessful = (err == nil)
  629. }
  630. // try certfp
  631. if !loginSuccessful && rb.session.certfp != "" {
  632. err = server.accounts.AuthenticateByCertFP(client, rb.session.certfp, "")
  633. loginSuccessful = (err == nil)
  634. }
  635. nickFixupFailed := false
  636. if loginSuccessful {
  637. if !fixupNickEqualsAccount(client, rb, server.Config()) {
  638. loginSuccessful = false
  639. // fixupNickEqualsAccount sends its own error message, don't send another
  640. nickFixupFailed = true
  641. }
  642. }
  643. if loginSuccessful {
  644. sendSuccessfulAccountAuth(client, rb, true, true)
  645. } else if !nickFixupFailed {
  646. nsNotice(rb, fmt.Sprintf(client.t("Authentication failed: %s"), authErrorToMessage(server, err)))
  647. }
  648. }
  649. func nsListHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  650. if !client.HasRoleCapabs("accreg") {
  651. nsNotice(rb, client.t("Insufficient privileges"))
  652. return
  653. }
  654. var searchRegex *regexp.Regexp
  655. if len(params) > 0 {
  656. var err error
  657. searchRegex, err = regexp.Compile(params[0])
  658. if err != nil {
  659. nsNotice(rb, client.t("Invalid regex"))
  660. return
  661. }
  662. }
  663. nsNotice(rb, ircfmt.Unescape(client.t("*** $bNickServ LIST$b ***")))
  664. nicks := server.accounts.AllNicks()
  665. for _, nick := range nicks {
  666. if searchRegex == nil || searchRegex.MatchString(nick) {
  667. nsNotice(rb, fmt.Sprintf(" %s", nick))
  668. }
  669. }
  670. nsNotice(rb, ircfmt.Unescape(client.t("*** $bEnd of NickServ LIST$b ***")))
  671. }
  672. func nsInfoHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  673. if !server.Config().Accounts.AuthenticationEnabled && !client.HasRoleCapabs("accreg") {
  674. nsNotice(rb, client.t("This command has been disabled by the server administrators"))
  675. return
  676. }
  677. var accountName string
  678. if len(params) > 0 {
  679. nick := params[0]
  680. if server.Config().Accounts.NickReservation.Enabled {
  681. accountName = server.accounts.NickToAccount(nick)
  682. if accountName == "" {
  683. nsNotice(rb, client.t("That nickname is not registered"))
  684. return
  685. }
  686. } else {
  687. accountName = nick
  688. }
  689. } else {
  690. accountName = client.Account()
  691. if accountName == "" {
  692. nsNotice(rb, client.t("You're not logged into an account"))
  693. return
  694. }
  695. }
  696. account, err := server.accounts.LoadAccount(accountName)
  697. if err != nil || !account.Verified {
  698. nsNotice(rb, client.t("Account does not exist"))
  699. return
  700. }
  701. nsNotice(rb, fmt.Sprintf(client.t("Account: %s"), account.Name))
  702. registeredAt := account.RegisteredAt.Format(time.RFC1123)
  703. nsNotice(rb, fmt.Sprintf(client.t("Registered at: %s"), registeredAt))
  704. // TODO nicer formatting for this
  705. for _, nick := range account.AdditionalNicks {
  706. nsNotice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick))
  707. }
  708. for _, channel := range server.accounts.ChannelsForAccount(accountName) {
  709. nsNotice(rb, fmt.Sprintf(client.t("Registered channel: %s"), channel))
  710. }
  711. }
  712. func nsRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  713. details := client.Details()
  714. passphrase := params[0]
  715. var email string
  716. if 1 < len(params) {
  717. email = params[1]
  718. }
  719. certfp := rb.session.certfp
  720. if passphrase == "*" {
  721. if certfp == "" {
  722. nsNotice(rb, client.t("You must be connected with TLS and a client certificate to do this"))
  723. return
  724. } else {
  725. passphrase = ""
  726. }
  727. }
  728. if !nsLoginThrottleCheck(client, rb) {
  729. return
  730. }
  731. config := server.Config()
  732. account := details.nick
  733. if config.Accounts.NickReservation.ForceGuestFormat {
  734. matches := config.Accounts.NickReservation.guestRegexp.FindStringSubmatch(account)
  735. if matches == nil || len(matches) < 2 {
  736. nsNotice(rb, client.t("Erroneous nickname"))
  737. return
  738. }
  739. account = matches[1]
  740. }
  741. var callbackNamespace, callbackValue string
  742. noneCallbackAllowed := false
  743. for _, callback := range config.Accounts.Registration.EnabledCallbacks {
  744. if callback == "*" {
  745. noneCallbackAllowed = true
  746. }
  747. }
  748. // XXX if ACC REGISTER allows registration with the `none` callback, then ignore
  749. // any callback that was passed here (to avoid confusion in the case where the ircd
  750. // has no mail server configured). otherwise, register using the provided callback:
  751. if noneCallbackAllowed {
  752. callbackNamespace = "*"
  753. } else {
  754. callbackNamespace, callbackValue = parseCallback(email, config.Accounts)
  755. if callbackNamespace == "" || callbackValue == "" {
  756. nsNotice(rb, client.t("Registration requires a valid e-mail address"))
  757. return
  758. }
  759. }
  760. err := server.accounts.Register(client, account, callbackNamespace, callbackValue, passphrase, rb.session.certfp)
  761. if err == nil {
  762. if callbackNamespace == "*" {
  763. err = server.accounts.Verify(client, account, "")
  764. if err == nil && fixupNickEqualsAccount(client, rb, config) {
  765. sendSuccessfulRegResponse(client, rb, true)
  766. }
  767. } else {
  768. messageTemplate := client.t("Account created, pending verification; verification code has been sent to %s")
  769. message := fmt.Sprintf(messageTemplate, callbackValue)
  770. nsNotice(rb, message)
  771. }
  772. } else {
  773. // details could not be stored and relevant numerics have been dispatched, abort
  774. message, _ := registrationErrorToMessageAndCode(err)
  775. nsNotice(rb, client.t(message))
  776. }
  777. }
  778. func nsSaregisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  779. var account, passphrase string
  780. account = params[0]
  781. if 1 < len(params) && params[1] != "*" {
  782. passphrase = params[1]
  783. }
  784. err := server.accounts.SARegister(account, passphrase)
  785. if err != nil {
  786. var errMsg string
  787. if err == errAccountAlreadyRegistered || err == errAccountAlreadyVerified {
  788. errMsg = client.t("Account already exists")
  789. } else if err == errAccountBadPassphrase {
  790. errMsg = client.t("Passphrase contains forbidden characters or is otherwise invalid")
  791. } else {
  792. server.logger.Error("services", "unknown error from saregister", err.Error())
  793. errMsg = client.t("Could not register")
  794. }
  795. nsNotice(rb, errMsg)
  796. } else {
  797. nsNotice(rb, fmt.Sprintf(client.t("Successfully registered account %s"), account))
  798. server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Operator $c[grey][$r%s$c[grey]] registered account $c[grey][$r%s$c[grey]] with SAREGISTER"), client.Oper().Name, account))
  799. }
  800. }
  801. func nsUnregisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  802. erase := command == "erase"
  803. username := params[0]
  804. var verificationCode string
  805. if len(params) > 1 {
  806. verificationCode = params[1]
  807. }
  808. if username == "" {
  809. nsNotice(rb, client.t("You must specify an account"))
  810. return
  811. }
  812. var accountName string
  813. var registeredAt time.Time
  814. if erase {
  815. // account may not be in a loadable state, e.g., if it was unregistered
  816. accountName = username
  817. // make the confirmation code nondeterministic for ERASE
  818. registeredAt = server.ctime
  819. } else {
  820. account, err := server.accounts.LoadAccount(username)
  821. if err == errAccountDoesNotExist {
  822. nsNotice(rb, client.t("Invalid account name"))
  823. return
  824. } else if err != nil {
  825. nsNotice(rb, client.t("Internal error"))
  826. return
  827. }
  828. accountName = account.Name
  829. registeredAt = account.RegisteredAt
  830. }
  831. if !(accountName == client.AccountName() || client.HasRoleCapabs("accreg")) {
  832. nsNotice(rb, client.t("Insufficient oper privs"))
  833. return
  834. }
  835. expectedCode := utils.ConfirmationCode(accountName, registeredAt)
  836. if expectedCode != verificationCode {
  837. if erase {
  838. nsNotice(rb, ircfmt.Unescape(client.t("$bWarning: erasing this account will allow it to be re-registered; consider UNREGISTER instead.$b")))
  839. } else {
  840. nsNotice(rb, ircfmt.Unescape(client.t("$bWarning: unregistering this account will remove its stored privileges.$b")))
  841. }
  842. nsNotice(rb, fmt.Sprintf(client.t("To confirm, run this command: %s"), fmt.Sprintf("/NS %s %s %s", strings.ToUpper(command), accountName, expectedCode)))
  843. return
  844. }
  845. err := server.accounts.Unregister(accountName, erase)
  846. if err == errAccountDoesNotExist {
  847. nsNotice(rb, client.t(err.Error()))
  848. } else if err != nil {
  849. nsNotice(rb, client.t("Error while unregistering account"))
  850. } else {
  851. nsNotice(rb, fmt.Sprintf(client.t("Successfully unregistered account %s"), accountName))
  852. server.logger.Info("accounts", "client", client.Nick(), "unregistered account", accountName)
  853. client.server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Client $c[grey][$r%s$c[grey]] unregistered account $c[grey][$r%s$c[grey]]"), client.NickMaskString(), accountName))
  854. }
  855. }
  856. func nsVerifyHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  857. username, code := params[0], params[1]
  858. err := server.accounts.Verify(client, username, code)
  859. var errorMessage string
  860. if err != nil {
  861. switch err {
  862. case errAccountAlreadyLoggedIn, errAccountVerificationInvalidCode, errAccountAlreadyVerified:
  863. errorMessage = err.Error()
  864. default:
  865. errorMessage = errAccountVerificationFailed.Error()
  866. }
  867. }
  868. if errorMessage != "" {
  869. nsNotice(rb, client.t(errorMessage))
  870. return
  871. }
  872. if fixupNickEqualsAccount(client, rb, server.Config()) {
  873. sendSuccessfulRegResponse(client, rb, true)
  874. }
  875. }
  876. func nsPasswdHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  877. var target string
  878. var newPassword string
  879. var errorMessage string
  880. hasPrivs := client.HasRoleCapabs("accreg")
  881. switch len(params) {
  882. case 2:
  883. if !hasPrivs {
  884. errorMessage = `Insufficient privileges`
  885. } else {
  886. target, newPassword = params[0], params[1]
  887. if newPassword == "*" {
  888. newPassword = ""
  889. }
  890. }
  891. case 3:
  892. target = client.Account()
  893. if target == "" {
  894. errorMessage = `You're not logged into an account`
  895. } else if params[1] != params[2] {
  896. errorMessage = `Passwords do not match`
  897. } else {
  898. if !nsLoginThrottleCheck(client, rb) {
  899. return
  900. }
  901. accountData, err := server.accounts.LoadAccount(target)
  902. if err != nil {
  903. errorMessage = `You're not logged into an account`
  904. } else {
  905. hash := accountData.Credentials.PassphraseHash
  906. if hash != nil && passwd.CompareHashAndPassword(hash, []byte(params[0])) != nil {
  907. errorMessage = `Password incorrect`
  908. } else {
  909. newPassword = params[1]
  910. if newPassword == "*" {
  911. newPassword = ""
  912. }
  913. }
  914. }
  915. }
  916. default:
  917. errorMessage = `Invalid parameters`
  918. }
  919. if errorMessage != "" {
  920. nsNotice(rb, client.t(errorMessage))
  921. return
  922. }
  923. err := server.accounts.setPassword(target, newPassword, hasPrivs)
  924. switch err {
  925. case nil:
  926. nsNotice(rb, client.t("Password changed"))
  927. case errEmptyCredentials:
  928. nsNotice(rb, client.t("You can't delete your password unless you add a certificate fingerprint"))
  929. case errCredsExternallyManaged:
  930. nsNotice(rb, client.t("Your account credentials are managed externally and cannot be changed here"))
  931. case errCASFailed:
  932. nsNotice(rb, client.t("Try again later"))
  933. default:
  934. server.logger.Error("internal", "could not upgrade user password:", err.Error())
  935. nsNotice(rb, client.t("Password could not be changed due to server error"))
  936. }
  937. }
  938. func nsEnforceHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  939. newParams := []string{"enforce"}
  940. if len(params) == 0 {
  941. nsGetHandler(server, client, "get", newParams, rb)
  942. } else {
  943. newParams = append(newParams, params[0])
  944. nsSetHandler(server, client, "set", newParams, rb)
  945. }
  946. }
  947. func nsSessionsHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  948. target := client
  949. if 0 < len(params) {
  950. target = server.clients.Get(params[0])
  951. if target == nil {
  952. nsNotice(rb, client.t("No such nick"))
  953. return
  954. }
  955. // same permissions check as RPL_WHOISACTUALLY for now:
  956. if target != client && !client.HasMode(modes.Operator) {
  957. nsNotice(rb, client.t("Command restricted"))
  958. return
  959. }
  960. }
  961. sessionData, currentIndex := target.AllSessionData(rb.session)
  962. nsNotice(rb, fmt.Sprintf(client.t("Nickname %[1]s has %[2]d attached session(s)"), target.Nick(), len(sessionData)))
  963. for i, session := range sessionData {
  964. if currentIndex == i {
  965. nsNotice(rb, fmt.Sprintf(client.t("Session %d (currently attached session):"), i+1))
  966. } else {
  967. nsNotice(rb, fmt.Sprintf(client.t("Session %d:"), i+1))
  968. }
  969. if session.deviceID != "" {
  970. nsNotice(rb, fmt.Sprintf(client.t("Device ID: %s"), session.deviceID))
  971. }
  972. nsNotice(rb, fmt.Sprintf(client.t("IP address: %s"), session.ip.String()))
  973. nsNotice(rb, fmt.Sprintf(client.t("Hostname: %s"), session.hostname))
  974. nsNotice(rb, fmt.Sprintf(client.t("Created at: %s"), session.ctime.Format(time.RFC1123)))
  975. nsNotice(rb, fmt.Sprintf(client.t("Last active: %s"), session.atime.Format(time.RFC1123)))
  976. if session.certfp != "" {
  977. nsNotice(rb, fmt.Sprintf(client.t("Certfp: %s"), session.certfp))
  978. }
  979. }
  980. }
  981. func nsCertHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  982. verb := strings.ToLower(params[0])
  983. params = params[1:]
  984. var target, certfp string
  985. switch verb {
  986. case "list":
  987. if 1 <= len(params) {
  988. target = params[0]
  989. }
  990. case "add", "del":
  991. if 2 <= len(params) {
  992. target, certfp = params[0], params[1]
  993. } else if len(params) == 1 {
  994. certfp = params[0]
  995. } else {
  996. nsNotice(rb, client.t("Invalid parameters"))
  997. return
  998. }
  999. default:
  1000. nsNotice(rb, client.t("Invalid parameters"))
  1001. return
  1002. }
  1003. hasPrivs := client.HasRoleCapabs("accreg")
  1004. if target != "" && !hasPrivs {
  1005. nsNotice(rb, client.t("Insufficient privileges"))
  1006. return
  1007. } else if target == "" {
  1008. target = client.Account()
  1009. if target == "" {
  1010. nsNotice(rb, client.t("You're not logged into an account"))
  1011. return
  1012. }
  1013. }
  1014. var err error
  1015. switch verb {
  1016. case "list":
  1017. accountData, err := server.accounts.LoadAccount(target)
  1018. if err == errAccountDoesNotExist {
  1019. nsNotice(rb, client.t("Account does not exist"))
  1020. return
  1021. } else if err != nil {
  1022. nsNotice(rb, client.t("An error occurred"))
  1023. return
  1024. }
  1025. certfps := accountData.Credentials.Certfps
  1026. nsNotice(rb, fmt.Sprintf(client.t("There are %[1]d certificate fingerprint(s) authorized for account %[2]s."), len(certfps), accountData.Name))
  1027. for i, certfp := range certfps {
  1028. nsNotice(rb, fmt.Sprintf("%d: %s", i+1, certfp))
  1029. }
  1030. return
  1031. case "add":
  1032. err = server.accounts.addRemoveCertfp(target, certfp, true, hasPrivs)
  1033. case "del":
  1034. err = server.accounts.addRemoveCertfp(target, certfp, false, hasPrivs)
  1035. }
  1036. switch err {
  1037. case nil:
  1038. if verb == "add" {
  1039. nsNotice(rb, client.t("Certificate fingerprint successfully added"))
  1040. } else {
  1041. nsNotice(rb, client.t("Certificate fingerprint successfully removed"))
  1042. }
  1043. case errNoop:
  1044. if verb == "add" {
  1045. nsNotice(rb, client.t("That certificate fingerprint was already authorized"))
  1046. } else {
  1047. nsNotice(rb, client.t("Certificate fingerprint not found"))
  1048. }
  1049. case errAccountDoesNotExist:
  1050. nsNotice(rb, client.t("Account does not exist"))
  1051. case errLimitExceeded:
  1052. nsNotice(rb, client.t("You already have too many certificate fingerprints"))
  1053. case utils.ErrInvalidCertfp:
  1054. nsNotice(rb, client.t("Invalid certificate fingerprint"))
  1055. case errCertfpAlreadyExists:
  1056. nsNotice(rb, client.t("That certificate fingerprint is already associated with another account"))
  1057. case errEmptyCredentials:
  1058. nsNotice(rb, client.t("You can't remove all your certificate fingerprints unless you add a password"))
  1059. case errCredsExternallyManaged:
  1060. nsNotice(rb, client.t("Your account credentials are managed externally and cannot be changed here"))
  1061. case errCASFailed:
  1062. nsNotice(rb, client.t("Try again later"))
  1063. default:
  1064. server.logger.Error("internal", "could not modify certificates:", err.Error())
  1065. nsNotice(rb, client.t("An error occurred"))
  1066. }
  1067. }