README 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. debianqueued -- daemon for managing Debian upload queues
  2. ========================================================
  3. Copyright (C) 1997 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
  4. $Id: README,v 1.20 1999/07/08 09:35:37 ftplinux Exp $
  5. Copyright and Disclaimer
  6. ------------------------
  7. This program is free software. You can redistribute it and/or
  8. modify it under the terms of the GNU General Public License as
  9. published by the Free Software Foundation: either version 2 or
  10. (at your option) any later version.
  11. This program comes with ABSOLUTELY NO WARRANTY!
  12. You're free to modify this program at your will, according to the GPL,
  13. and I don't object if you modify the program. But it would be nice if
  14. you could send me back such changes if they could be of public
  15. interest. I will try to integrate them into the mainstream version
  16. then.
  17. Installation
  18. ------------
  19. debianqueued has been written for running a new Debian upload queue at
  20. ftp.uni-erlangen.de, but I tried to keep it as general as possible and
  21. it should be useable for other sites, too. If there should be
  22. non-portabilities, tell me about them and we'll try to get them fixed!
  23. Before installing debianqueued, you should have the following
  24. utilities installed:
  25. - pgp (needed for checking signatures)
  26. - ssh & Co. (but not necessarily sshd, only client programs used)
  27. - md5sum (for checking file integrity)
  28. - mkfifo (for creating the status FIFO)
  29. - GNU tar
  30. - gzip
  31. - ar (for analyzing .deb files)
  32. The daemon needs a directory of its own where the scripts reside and
  33. where it can put certain files. This directory is called $queued_dir
  34. in the Perl scripts and below. There are no special requirements where
  35. in the filesystem hierarchy this directory should be.
  36. All configurations are done in file 'config' in $queued_dir. For
  37. security reasons, the $queued_dir should not be in a public FTP area,
  38. and should be writeable (as the files in it) only for the user
  39. maintaining the local debianqueued.
  40. The file Queue.README and Queue.message in the distribution archive
  41. are examples for README and .message files to put into the queue
  42. directory. Modify them as you like, or don't install them if you
  43. don't like them...
  44. Running debianqueued
  45. --------------------
  46. debianqueued is intended to run all time, not as a cron job.
  47. Unfortunately, you can't start it at system boot time automatically,
  48. because a human has to type in the pass phrase for the ssh key. So you
  49. have to start the daemon manually.
  50. The daemon can be stopped by simply killing it (with SIGTERM
  51. preferrably). SIGTERM and SIGINT are blocked during some operations,
  52. where it could leave files in a inconsistent state. So it make take
  53. some time until the daemon really dies. If you have the urgent need
  54. that it goes away immediately, use SIGQUIT. Please don't use SIGKILL
  55. except unavoidable, because the daemon can't clean up after this
  56. signal.
  57. For your convenience, the daemon can kill and restart itself. If you
  58. start debianqueued with a "-k" argument, it tries to kill a running
  59. daemon (and it complains if none is running.) If "-r" is on the
  60. command line, it tries to kill a running daemon first if there is one.
  61. (If not, it starts anyway, but prints a little warning.) If a daemon
  62. is running and a new one is started without "-r", you get an error
  63. message about this. This is to protect you from restarting the daemon
  64. without intention.
  65. The other script, dqueued-watcher, is intended as cron job, and it
  66. watches that the daemon is running, in case that it should crash
  67. sometimes. It also takes care of updating the Debian keyring files if
  68. necessary. You should enter it e.g. like
  69. 0,30 * * * * .../dqueued-watcher
  70. into your crontab. (Assuming you want to run it every 30 minutes,
  71. which seems a good compromise.)
  72. Both scripts (debianqueued and dqueued-watcher) need no special
  73. priviledges and thus can be run as an ordinary user (not root). You
  74. can create an own user for debianqueued (e.g. "dqueue"), but you need
  75. not. The only difference could be which ssh key is used for connects
  76. to the target host. But you can configure the file to take the ssh key
  77. from in the config file.
  78. The Config File
  79. ---------------
  80. The config file, $queued_dir/config, is plain Perl code and is
  81. included by debianqueued and dqueued-watcher. You can set the
  82. following variables there:
  83. - $debug:
  84. Non-zero values enable debugging output (to log file).
  85. The following are all programs that debianqueued calls. You should
  86. always use absolute pathnames!
  87. - $pgp, $ssh, $scp, $ssh_agent, $ssh_add, $md5sum, $mail, $mkfifo,
  88. $tar, $gzip, $ar
  89. Notes:
  90. o $mail should support the -s option for supplying a subject.
  91. Therefore choose mailx if your mail doesn't know -s.
  92. o $tar should be GNU tar, several GNU features are used (e.g.
  93. --use-compress-program).
  94. o $ar must be able to unpack *.deb files and must understand the
  95. 'p' command. Better check this first... If you don't define $ar
  96. (or define it to be empty), debianqueued won't be able to
  97. extract a maintainer address from .deb files. (Which isn't that
  98. disturbing...)
  99. - @test_binaries:
  100. All binaries listed in this variable are tested to be present
  101. before each queue run. If any is not available, the queue run is
  102. delayed. This test can be useful if those binaries reside on NFS
  103. filesystems which may be (auto-)mounted only slowly. It is
  104. specially annoying for users if pgp can't be found and a .changes
  105. is deleted.
  106. - $ssh_options:
  107. Options passed to ssh and scp on every call. General ssh
  108. configuration should be done here and not in ~/.ssh/config, to
  109. avoid dependency on the user's settings. A good idea for
  110. $ssh_options seems to be
  111. -o'BatchMode yes' -o'FallBackToRsh no' -o'ForwardAgent no'
  112. -o'ForwardX11 no' -o'PasswordAuthentication no'
  113. -o'StrictHostKeyChecking yes'
  114. - $ssh_key_file:
  115. The file containing the ssh key you want the daemon to use for
  116. connects to the target host. If you leave this empty, the default
  117. ~/.ssh/identity is used, which may or may not be what you want.
  118. - $incoming:
  119. This names the queue directory itself. Probably it will be inside
  120. the public FTP area. Don't forget to allow uploads to it in
  121. ftpaccess if you're using wu-ftpd.
  122. Maybe you should also allow anonymous users to rename files in that
  123. directory, to fix upload problems (they can't delete files, so they
  124. have to move the errorneous file out of the way). But this
  125. introduces a denial-of-service security hole, that an attacker
  126. renames files of other people and then a job won't be done. But at
  127. least the data aren't lost, and the rename command probably was
  128. logged by ftpd. Nevertheless, there's no urgent need to allow
  129. renamings, because the queue daemon deletes all bad files
  130. automatically, so they can be reuploaded under the same name.
  131. Decide on your own...
  132. - $keep_files:
  133. This is a regular expression for files that never should be deleted
  134. in the queue directory. The status file must be included here,
  135. other probable candicates are .message and/or README files.
  136. - $chmod_on_target:
  137. If this variable is true (i.e., not 0 or ""), all files belonging
  138. to a job are changed to mode 644 only on the target host. The
  139. alternative (if the variable is false, i.e. 0) is to change the
  140. mode already locally, after the sizes and md5 sums have been
  141. verified. The latter is the default.
  142. The background for this is the following: The files must be
  143. word-readable on master for dinstall to work, so they must be at
  144. least mode 444, but 644 seems more useful. If the upload policy of
  145. your site says that uploaded files shouldn't be readable for world,
  146. the queue daemon has to change the permission at some point of
  147. time. (scp copies a file's permissions just as the contents, so
  148. after scp, the files on the target have the same mode as in the
  149. queue directory.) If the files in the queue are mode 644 anyway,
  150. you don't need to care about this option. The default --to give
  151. word read permission in the queue already after some checks-- is
  152. obviously less restrictive, but might be against the policy of your
  153. site. The alternative keeps the files unreadable in the queue in
  154. any case, and they'll be readable only on the target host.
  155. - $statusfile:
  156. This is the name of the status file or FIFO, through which users
  157. can ask the daemon what it's currently doing. It should normally be
  158. in the queue directory. If you change the name, please don't forget
  159. to check $keep_files. See also the own section on the status file.
  160. If you leave $statusfile empty, the daemon doesn't create and
  161. manage a status file at all, if you don't want it. Unfortunately,
  162. dqueued-watcher's algorithm to determine whether it already has
  163. reported a missing daemon depends on the status file, so this
  164. doesn't work anymore in this case. You'll get dead daemon mails on
  165. every run of dqueued-watcher.
  166. - $statusdelay:
  167. If this number is greater than 0, the status file is implemented as
  168. a regular file, and updated at least every $statusdelay seconds. If
  169. $statusdelay is 0, the FIFO implementation is used (see status file
  170. section).
  171. - $keyring:
  172. The name of the PGP keyring the daemon uses to check PGP signatures
  173. of .changes files. This is usually $queued_dir/debian-keyring.pgp.
  174. It should contain exactly the keys of all Debian developers (i.e.
  175. those and no other keys).
  176. - $gpg_keyring:
  177. The name of the GnuPG keyring. The daemon now alternatively accepts
  178. GnuPG signatures on .changes and .commands files. The value here is
  179. usually $queued_dir/debian-keyring.gpg. It should contain only keys
  180. of Debian developers (but not all developers have a GPG key
  181. yet...).
  182. - $keyring_archive:
  183. Path of the debian-keyring.tar.gz file inside a Debian mirror. The
  184. file is "/debian/doc/debian-keyring.tar.gz" on ftp.debian.org,
  185. don't know where you mirror it to... Leave it empty if you don't
  186. have that file on your local machine. But then you'll have to
  187. update the keyring manually from time to time.
  188. - $keyring_archive_name:
  189. Name of the PGP keyring file in the archive $keyring_archive. Currently
  190. "debian-keyring*/debian-keyring.pgp".
  191. - $gpg_keyring_archive_name:
  192. Name of the GnuPG keyring file in the archive $keyring_archive. Currently
  193. "debian-keyring*/debian-keyring.gpg".
  194. - $logfile:
  195. The file debianqueued writes its logging data to. Usually "log" in
  196. $queued_dir.
  197. - $pidfile:
  198. The file debianqueued writes its pid to. Usually "pid" in
  199. $queued_dir.
  200. - $target:
  201. Name of the target host, i.e. the host where the queue uploads to.
  202. Usually "master.debian.org". (Ignored with "copy" upload method.)
  203. - $targetlogin:
  204. The login on the target to use for uploads. (Ignored with "copy"
  205. and "ftp" upload methods; "ftp" always does anonymous logins.)
  206. - $targetdir:
  207. The directory on the target to where files should be uploaded. On
  208. master.debian.org this currently is
  209. "/home/Debian/ftp/private/project/Incoming".
  210. - $max_upload_retries:
  211. This is the number how often the daemon tries to upload a job (a
  212. .changes + the files belonging to it). After that number is
  213. exhausted, all these files are deleted.
  214. - $log_age:
  215. This is how many days are waited before logfiles are rotated. (The
  216. age of the current log files is derived from the first date found
  217. in it.)
  218. - $log_keep:
  219. How many old log files to keep. The current logfile is what you
  220. configured as $logfile above, older versions have ".0", ".1.gz",
  221. ".2.gz", ... appended. I.e., all old versions except the first are
  222. additionally gzipped. $log_keep is one higher than the max.
  223. appended number that should exist.
  224. - $mail_summary:
  225. If this is set to a true value (not 0 and not ""), dqueued-watcher
  226. will send a mail with a summary of the daemon's acivities whenever
  227. logfiles are rotated.
  228. - $summary_file:
  229. If that value is a file name (and not an empty string),
  230. dqueued-watcher will write the same summary of daemon activities as
  231. above to the named file. This can be in addition to sending a mail.
  232. - @nonus_packages:
  233. This is a (Perl) list of names of packages that must be uploaded to
  234. nonus.debian.org and not to master. Since the queue daemon only can
  235. deal with one target, it can't do that upload and thus must reject
  236. the job. Generally you can treat this variable as a list of any
  237. packages that should be rejected.
  238. All the following timing variables are in seconds:
  239. - $upload_delay_1:
  240. The time between the first (failed) upload try and the next one.
  241. Usually shorter then $upload_delay_2 for quick retry after
  242. transient errors.
  243. - $upload_delay_2:
  244. The time between the following (except the first) upload retries.
  245. - $queue_delay:
  246. The time between two queue runs. (May not be obeyed too exactly...
  247. a few seconds deviation are normal).
  248. - $stray_remove_timeout:
  249. If a file not associated with any .changes file is found in the
  250. queue directory, it is removed after this many seconds.
  251. - $problem_report_timeout:
  252. If there are problems with a job that could also be result of a
  253. not-yet-complete upload (missing or too small files), the daemon
  254. waits this long before reporting the problem to the uploader. This
  255. avoids warning mails for slow but ongoing uploads.
  256. - $no_changes_timeout:
  257. If files are found in the queue directory that look like a Debian
  258. upload (*.tar.gz, *.diff.gz, *.deb, or *.dsc files), but aren't
  259. accompanied by a .changes file, then debianqueued tries to notify
  260. the uploader after $no_changes_timeout seconds about this. This
  261. value is somewhat similar to $problem_report_timeout, and the
  262. values can be equal.
  263. Since there's no .changes, the daemon can't never be sure who
  264. really uploaded the files, but it tries to extract the maintainer
  265. address from all of the files mentioned above. If they're real
  266. Debian files (except a .orig.tar.gz), this works in most cases.
  267. - $bad_changes_timeout:
  268. After this time, a job with persisting problems (missing files,
  269. wrong size or md5 checksum) is removed.
  270. - $remote_timeout:
  271. This is the maximum time a remote command (ssh/scp) may take. It's
  272. to protect against network unreliabilities and the like. Choose the
  273. number sufficiently high, so that the timeout doesn't inadventedly
  274. kill a longish upload. A few hours seems ok.
  275. Contents of $queued_dir
  276. -----------------------
  277. $queued_dir contains usually the following files:
  278. - config:
  279. The configuration file, described above.
  280. - log:
  281. Log file of debianqueued. All interesting actions and errors are
  282. logged there, in a format similar to syslog.
  283. - pid:
  284. This file contains the pid of debianqueued, to detect double
  285. daemons and for killing a running daemon.
  286. - debian-keyring.pgp, debian-keyring.gpg:
  287. These are the PGP and GnuPG key rings used by debianqueued to
  288. verify the signatures of .changes files. It should contain the keys
  289. of all Debian developers and no other keys. The current Debian key
  290. ring can be obtained from
  291. ftp.debian.org:/debian/doc/debian-keyring.tar.gz. dqueued-watcher
  292. supports the facility to update this file automatically if you also
  293. run a Debian mirror.
  294. - debianqueued, dqueued-watcher:
  295. The Perl scripts.
  296. All filenames except "config" can be changed in the config file. The
  297. files are not really required to reside in $queued_dir, but it seems
  298. practical to have them all together...
  299. Details of Queue Processing
  300. ---------------------------
  301. The details of how the files in the queue are processed may be a bit
  302. complicated. You can skip this section if you're not interested in
  303. those details and everything is running fine... :-)
  304. The first thing the daemon does on every queue run is determining all
  305. the *.changes files present. All of them are subsequently read and
  306. analyzed. The .changes MUST contain a Maintainer: field, and the
  307. contents of that field should be the mail address of the uploader. The
  308. address is used for sending back acknowledges and error messages.
  309. (dinstall on master uses the same convention.)
  310. Next, the PGP or GnuPG signature of the .changes is checked. The
  311. signature must be valid and must belong to one of the keys in the
  312. Debian keyring (see config variables $keyring and $gpg_keyring). This
  313. ensures that only registered Debian developers can use the upload
  314. queue to transfer files to master.
  315. Then all files mentioned in the Files: field of the .changes are
  316. checked. All of them must be present, and must have correct size and
  317. md5 checksum. If any of this conditions is violated, the upload
  318. doesn't happen and an error message is sent to the uploader. If the
  319. error is a incorrect size/md5sum, the file is also deleted, because it
  320. has to be reuploaded anyway, and it could be the case that the
  321. uploader cannot easily overwrite a file in the queue dir (due to
  322. upload permission restrictions). If the error is a missing file or a
  323. too small file, the error message is hold back for some time
  324. ($problems_report_timeout), because they can also be result of an
  325. not-yet-complete upload.
  326. The time baseline for when to send such a problem report is the
  327. maximum modification time of the .changes itself and all files
  328. mentioned in it. When such a report is sent, the setgid bit (show as
  329. 'S' in ls -l listing, in group x position) on the .changes is set to
  330. note that fact, and to avoid the report being sent on every following
  331. queue run. If any modification time becomes greater than the time the
  332. setgid bit was set, a new problem report is sent, because obviously
  333. something has changed to the files.
  334. If a job is hanging around for too long with errors
  335. ($bad_changes_timeout), the .changes and all its files are deleted.
  336. The base for that timeout is again the maximum modification time as
  337. explained above.
  338. If now the .changes itself and all its files are ok, an upload is
  339. tried. The upload itself is done with scp. In that stage, various
  340. errors from the net and/or ssh can occur. All these simply count as
  341. upload failures, since it's not easy to distinguish transient and
  342. permanent failures :-( If the scp goes ok, the md5sums of the files on
  343. the target are compared with the local ones. This is to ensure that
  344. the transfer didn't corrupt anything. On any error in the upload or in
  345. the md5 check, the files written to the target host are deleted again
  346. (they may be broken), and an error message is sent to the uploader.
  347. The upload is retied $upload_delay_1 seconds later. If it fails again,
  348. the next retries have a (longer) delay $upload_delay_2 between them.
  349. At most $max_upload_retries retries are done. After all these failed,
  350. all the files are deleted, since it seems we can't move them... For
  351. remembering how many tries were alredy done (and when), debianqueued
  352. uses a separate file. Its name is the .changes' filename with
  353. ".failures" appended. It contains simply two integers, the retry count
  354. and the last upload time (in Unix time format).
  355. After a successfull upload, the daemon also checks for files that look
  356. like they belonged to the same job, but weren't listed in the
  357. .changes. Due to experience, this happens rather often with
  358. .orig.tar.gz files, which people upload though they're aren't needed
  359. nor mentioned in the .changes. The daemon uses the filename pattern
  360. <pkg-name>_<version>* to find such unneeded files, where the Debian
  361. revision is stripped from <version>. The latter is needed to include
  362. .orig.tar.gz files, which don't have the Debian revision part. But
  363. this also introduces the possibility that files of another upload for
  364. the same package but with another revision are deleted though they
  365. shouldn't. However, this case seems rather unlikely, so I didn't care
  366. about it. If such files are deleted, that fact is mentioned in the
  367. reply mail to the uploader.
  368. If any files are found in the queue dir that don't belong to any
  369. .changes, they are considered "stray". Such files are remove after
  370. $stray_remove_timeout. This should be around 1 day or so, to avoid
  371. files being removed that belong to a job, but whose .changes is still
  372. to come. The daemon also tries to find out whether such stray files
  373. could be part of an incomplete upload, where the .changes file is
  374. still missing or has been forgotten. Files that match the patterns
  375. *.deb, *.dsc, *.diff.gz, or *.tar.gz are analyzed whether a maintainer
  376. address can be extracted from them. If yes, the maintainer is notified
  377. about the incomplete upload after $no_changes_timeout seconds.
  378. However, the maintainer needs not really be the uploader... It could
  379. be a binary-only upload for another architecture, or a non-maintainer
  380. upload. In these cases, the mail goes to the wrong wrong person :-(
  381. But better than not writing at all, IMHO...
  382. The status file
  383. ---------------
  384. debianqueued provides a status file for the user in the queue
  385. directory. By reading this file, the user can get an idea what the
  386. daemon is currently doing.
  387. There are two possible implementations of the status file: as a plain
  388. file, or as a named pipe (FIFO). Both have their advantages and
  389. disadvantages.
  390. If using the FIFO, the data printed (last ping time, next queue run)
  391. are always up to date, because they're interrogated (by a signal) just
  392. at the time the FIFO is opened for reading. Also, the daemon hasn't to
  393. care about the status file if nobody accesses it. The bad things about
  394. the FIFO: It is a potential portability problem, because not all
  395. systems have FIFOs, or they behave different than I expect... But the
  396. more severe problem: wu-ftpd refuses to send the contents of a FIFO on
  397. a FTP GET request :-(( It does an explicit check whether a file to be
  398. retrieved is a regular file. This can be easily patched [1], but not
  399. everybody wants to do that or can do that (but I did it for
  400. ftp.uni-erlangen.de). (BTW, there could still be problems (races) if
  401. more than one process try to read the status file at the same time...)
  402. The alternative is using a plain file, which is updated regularily by
  403. the daemon. This works on every system, but causes more overhead (the
  404. daemon has to wake up each $statusdelay seconds and write a file), and
  405. the time figures in the file can't be exact. $statusdelay should be a
  406. compromise between CPU wastage and desired accuracy of the times found
  407. in the status file. I think 15 or 30 seconds should be ok, but your
  408. milage may vary.
  409. If the status file is a FIFO, the queue daemon forks a second process
  410. for watching the FIFO (so don't wonder if debianqueued shows up twice
  411. in ps output :-), to avoid blocking a reading process too long until
  412. the main daemon has time to watch the pipe. The status daemon requests
  413. data from the main daemon by sending a signal (SIGUSR1). Nevertheless
  414. it can happen that a process that opens the status file (for reading)
  415. is blocked, because the daemon has crashed (or never has been started,
  416. after reboot). To minimize chances for that situation, dqueued-watcher
  417. replaces the FIFO by a plain file (telling that the daemon is down) if
  418. it sees that no queue daemon is running.
  419. [1]: This is such a patch, for wu-ftpd-2.4.2-BETA-13:
  420. --- wu-ftpd/src/ftpd.c~ Wed Jul 9 13:18:44 1997
  421. +++ wu-ftpd/src/ftpd.c Wed Jul 9 13:19:15 1997
  422. @@ -1857,7 +1857,9 @@
  423. return;
  424. }
  425. if (cmd == NULL &&
  426. - (fstat(fileno(fin), &st) < 0 || (st.st_mode & S_IFMT) != S_IFREG)) {
  427. + (fstat(fileno(fin), &st) < 0 ||
  428. + ((st.st_mode & S_IFMT) != S_IFREG &&
  429. + (st.st_mode & S_IFMT) != S_IFIFO))) {
  430. reply(550, "%s: not a plain file.", name);
  431. goto done;
  432. }
  433. Command Files
  434. -------------
  435. The practical experiences with debianqueued showed that users
  436. sometimes make errors with their uploads, resulting in misnamed or
  437. corrupted files... Formerly they didn't have any chance to fix such
  438. errors, because the ftpd usually doesn't allow deleting or renaming
  439. files in the queue directory. (If you would allow this, *anybody* can
  440. remove/rename files, which isn't desirable.) So users had to wait
  441. until the daemon deleted the bad files (usually ~ 24 hours), before
  442. they could start the next try.
  443. To overcome this, I invented the *.command files. The daemon looks for
  444. such files just as it tests for *.changes files on every queue run,
  445. and processes them before the usual jobs. *.commands files must be PGP
  446. or GnuPG signed by a known Debian developer (same test as for
  447. *.changes), so only these people can give the daemon commands. Since
  448. Debian developers can also delete files in master's incoming, the
  449. *.commands feature doesn't give away any security.
  450. The syntax of a *.commands file is much like a *.changes, but it
  451. contains only two (mandatory) fields: Uploader: and Commands.
  452. Uploader: contains the e-mail address of the uploader for reply mails,
  453. and should have same contents as Maintainer: in a .changes. Commands:
  454. is a multi-line field like e.g. Description: or Changes:. Every
  455. continuation line must start with a space. Each line in Commands:
  456. contains a command for the daemon that looks like a shell command (but
  457. it isn't one, the daemon parses and executes it itself and doesn't use
  458. sh or the respective binaries).
  459. Example:
  460. -----BEGIN PGP SIGNED MESSAGE-----
  461. Hash: SHA256
  462. Uploader: Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
  463. Commands:
  464. rm hello_1.0-1_i386.deb
  465. mv hello_1.0-1.dsx hello_1.0-1.dsc
  466. -----BEGIN PGP SIGNATURE-----
  467. Version: GnuPG v1.4.12 (GNU/Linux)
  468. iQCVAwUBNFiQSXVhJ0HiWnvJAQG58AP+IDJVeSWmDvzMUphScg1EK0mvChgnuD7h
  469. BRiVQubXkB2DphLJW5UUSRnjw1iuFcYwH/lFpNpl7XP95LkLX3iFza9qItw4k2/q
  470. tvylZkmIA9jxCyv/YB6zZCbHmbvUnL473eLRoxlnYZd3JFaCZMJ86B0Ph4GFNPAf
  471. Z4jxNrgh7Bc=
  472. =pH94
  473. -----END PGP SIGNATURE-----
  474. The only commands implemented at this time are 'rm' and 'mv'. No
  475. options are implemented, and filenames may not contain slashes and are
  476. interpreted relative to the queue directory. This ensures that only
  477. files there can be modified. 'mv' always takes two arguments. 'rm' can
  478. take any number of args. It also knows about the following shell
  479. wildcard chars: *, ?, and [...]. {..,..} constructs are *not*
  480. supported. The daemon expands these patterns itself and doesn't use sh
  481. for that (for security reasons).
  482. *.commands files are processed before the usual *.changes jobs, so if
  483. a commands file fixes a job so that it can be processed, that
  484. processing happens in the same queue run and no unnecessary delay is
  485. introduced.
  486. The uploader of a *.commands will receive a reply mail with a comment
  487. (OK or error message) to each of the commands given. The daemon not
  488. only logs the contents of the Uploader: field, but also the owner of
  489. the PGP/GnuPG key that was used to sign the file. In case you want to
  490. find out who issued some commands, the Uploader: field is insecure,
  491. since its contents can't be checked.
  492. Security Considerations
  493. -----------------------
  494. You already know that debianqueued uses ssh & Co. to get access to
  495. master, or in general any target host. You also probably know that you
  496. need to unlock your ssh secret key with a passphrase before it can be
  497. used. For the daemon this creates a problem: It needs the passphrase
  498. to be able to use ssh/scp, but obviously you can't type in the phrase
  499. every time the daemon needs it... It would also be very ugly and
  500. insecure to write the passphase into some config file of the daemon!
  501. The solution is using ssh-agent, which comes with the ssh package.
  502. This agent's purpose is to store passphrases and give it to
  503. ssh/scp/... if they need it. ssh-agent has to ways how it can be
  504. accessed: through a Unix domain socket, or with an inherited file
  505. descriptor (ssh-agent is the father of your login shell then). The
  506. second method is much more secure than the first, because the socket
  507. can be easily exploited by root. On the other hand, an inherited file
  508. descriptor can be access *only* from a child process, so even root has
  509. bad chances to get its hands on it. Unfortunately, the fd method has
  510. been removed in ssh-1.2.17, so I STRONGLY recommend to use ssh-1.2.16.
  511. (You can still have a newer version for normal use, but separate
  512. binaries for debianqueued.) Also, using debianqueued with Unix domain
  513. sockets is basically untested, though I've heard that it doesn't
  514. work...
  515. debianqueued starts the ssh-agent automatically and runs ssh-add. This
  516. will ask you for your passphrase. The phrase is stored in the agent
  517. and available only to child processes of the agent. The agent will
  518. also start up a second instance of the queue daemon that notices that
  519. the agent is already running.
  520. Currently, there's no method to store the passphrase in a file, due to
  521. all the security disadvantages of this. If you don't mind this and
  522. would like to have some opportunity to do it nevertheless, please ask
  523. me. If there's enough demand, I'll do it.
  524. New Upload Methods
  525. ------------------
  526. Since release 0.9, debianqueued has two new upload methods as
  527. alternatives to ssh: copy and ftp.
  528. The copy method simply moves the files to another directory on the
  529. same host. This seems a bit silly, but is for a special purpose: The
  530. admins of master intend to run an upload queue there, too, in the
  531. future to avoid non-anonymous FTP connections, which transmit the
  532. password in cleartext. And, additionally to simply moving the files,
  533. the queue daemon also checks the signature and integrity of uploads
  534. and can reject non-US packages.
  535. The ftp method uploads to a standard anon-FTP incoming directory. The
  536. intention here is that you could create second-level queue daemons.
  537. I.e., those daemons would upload into the queue of another daemon
  538. (and, for example, this could be the queue of the daemon on master).
  539. However, the ftp method still has some limitations:
  540. 1) Files in the target dir can't be deleted.
  541. 2) Uploaded files can't be verified as good as with the other methods.
  542. 3) $chmod_on_target often doesn't work.
  543. 4) The check for a writable incoming directory leaves temporary files
  544. behind.
  545. Ad 1): In anon-FTP incoming directories removing of files usually
  546. isn't allowed (this would widely open doors to denial-of-service
  547. attacks). But debianqueued has to remove files on the target as part
  548. of handling upload errors. So if an transmission error happens during
  549. a job, the bad file can't be deleted. On the next try, the file is
  550. already present on the target and can't be overwritten, so all the
  551. following tries will fail, too, except the upstream queue daemon has
  552. deleted them already. And if the .changes was among the files already
  553. (at least partially) uploaded, the daemon even will think that the
  554. whole job is already present on the target and will delete the job in
  555. its queue.
  556. Ad 2): Uploaded files are usually verified with md5sum if they're
  557. really the same as the originals. But getting the md5sum for a file on
  558. a FTP server usually isn't possible. It's currently handled as
  559. follows: If the server supports a SITE MD5SUM command (non-standard!),
  560. then this is used and you have the same checking quality. Otherwise,
  561. debianqueued falls back to only comparing the file sizes. This is
  562. better than nothing, but doesn't detected changed contents that don't
  563. result in size changes.
  564. Ad 3): Often SITE CHMOD (standard) isn't allowed in incoming
  565. directories. If this is the case, $chmod_on_target must be off,
  566. otherwise all uploads will fail. The mode of uploaded files if forced
  567. anyway by the FTP server in most cases.
  568. Ad 4): As you know, the queue daemon has a special check if the target
  569. directory is writable at all (it isn't during a freeze) to protect
  570. against repeated upload errors. (Jobs would be even deleted otherwise
  571. if the target dir is unaccessible for too long.) This check is
  572. performed by creating a test file and deleting it immediately again.
  573. But since in FTP incoming dirs deletion isn't permitted, the temporary
  574. file ("junk-for-writable-test-DATE") will remain there. As a partial
  575. fix, the daemon deletes such files immediately, it doesn't even wait
  576. for $stray_remove_timeout. So if the upload goes to the queue dir of
  577. an upstream debianqueued, those temporary files won't be there for
  578. long.
  579. These problems of the FTP method might be remove in future, if I have
  580. better ideas how to bypass the limitations of anon-FTP incoming
  581. directories. Hints welcome :-)
  582. # Local Variables:
  583. # mode: indented-text
  584. # End: