OpenSDE Packages Database (without history before r20070)
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.

162 lines
5.7 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../cups-pdf/ForcedUser.patch
  5. # Copyright (C) 2005 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- T2-COPYRIGHT-NOTE-END ---
  16. This allows forcing all files to be created with a specific user or, if a
  17. unknown user is forced, to create the files as AnonUser, if allowed.
  18. - Rene Rebe <rene@exactcode.de>
  19. diff -ur cups-pdf-2.0beta2/extra/cups-pdf.conf cups-pdf-2.0beta2-imp/extra/cups-pdf.conf
  20. --- cups-pdf-2.0beta2/extra/cups-pdf.conf 2005-10-26 14:15:51.000000000 +0200
  21. +++ cups-pdf-2.0beta2-imp/extra/cups-pdf.conf 2005-12-06 19:20:01.000000000 +0100
  22. @@ -106,6 +106,13 @@
  23. #AnonUser nobody
  24. +### Key: ForcedUser
  25. +## fixed user for PDF creation (this might be a security issue)
  26. +## set this to an empty value to use the username supplied by CUPS
  27. +### Default: <empty>
  28. +
  29. +#ForcedUser archiver
  30. +
  31. ### Key: LowerCase
  32. ## This options allows to check user names given to CUPS-PDF additionally
  33. ## against their lower case variants. This is necessary since in some
  34. diff -ur cups-pdf-2.0beta2/src/cups-pdf.c cups-pdf-2.0beta2-imp/src/cups-pdf.c
  35. --- cups-pdf-2.0beta2/src/cups-pdf.c 2005-10-23 16:04:45.000000000 +0200
  36. +++ cups-pdf-2.0beta2-imp/src/cups-pdf.c 2005-12-06 19:44:50.000000000 +0100
  37. @@ -350,11 +350,12 @@
  38. }
  39. int main(int argc, char *argv[]) {
  40. - char *user, *dirname, *spoolfile, *outfile, *gscall, *ppcall;
  41. + char *dirname, *spoolfile, *outfile, *gscall, *ppcall;
  42. cp_string title="";
  43. - int size;
  44. + cp_string user="";
  45. mode_t mode;
  46. struct passwd *passwd;
  47. + int size;
  48. pid_t pid;
  49. if (getuid()) {
  50. @@ -376,15 +377,12 @@
  51. log_event(CPSTATUS, "call contained illegal number of arguments", NULL);
  52. return 0;
  53. }
  54. - size=strlen(conf.userprefix)+strlen(argv[2])+1;
  55. - user=calloc(size, sizeof(char));
  56. - if (user == NULL) {
  57. - fputs("CUPS-PDF: failed to allocate memory\n", stderr);
  58. - return -2;
  59. - }
  60. - snprintf(user, size, "%s%s", conf.userprefix, argv[2]);
  61. + if (*conf.forceduser != 0)
  62. + snprintf(user, BUFSIZE, "%s", conf.forceduser);
  63. + else
  64. + snprintf(user, BUFSIZE, "%s%s", conf.userprefix, argv[2]);
  65. passwd=getpwnam(user);
  66. - if (passwd == NULL && conf.lowercase) {
  67. + if (passwd == NULL && conf.lowercase && *conf.forceduser == 0) {
  68. log_event(CPDEBUG, "unknown user", user);
  69. for (size=0;size<(int) strlen(argv[2]);size++)
  70. argv[2][size]=tolower(argv[2][size]);
  71. @@ -398,7 +396,6 @@
  72. passwd=getpwnam(conf.anonuser);
  73. if (passwd == NULL) {
  74. log_event(CPERROR, "username for anonymous access unknown", conf.anonuser);
  75. - free(user);
  76. fclose(logfp);
  77. return -2;
  78. }
  79. @@ -408,7 +405,6 @@
  80. dirname=calloc(size, sizeof(char));
  81. if (dirname == NULL) {
  82. fputs("CUPS-PDF: failed to allocate memory\n", stderr);
  83. - free(user);
  84. fclose(logfp);
  85. return -2;
  86. }
  87. @@ -419,7 +415,6 @@
  88. dirname=calloc(size, sizeof(char));
  89. if (dirname == NULL) {
  90. fputs("CUPS-PDF: failed to allocate memory\n", stderr);
  91. - free(user);
  92. fclose(logfp);
  93. return -2;
  94. }
  95. @@ -428,7 +423,6 @@
  96. }
  97. else {
  98. log_event(CPSTATUS, "anonymous access denied", user);
  99. - free(user);
  100. fclose(logfp);
  101. return 0;
  102. }
  103. @@ -441,7 +435,6 @@
  104. dirname=calloc(size, sizeof(char));
  105. if (dirname == NULL) {
  106. fputs("CUPS-PDF: failed to allocate memory\n", stderr);
  107. - free(user);
  108. fclose(logfp);
  109. return -2;
  110. }
  111. @@ -452,7 +445,6 @@
  112. dirname=calloc(size, sizeof(char));
  113. if (dirname == NULL) {
  114. fputs("CUPS-PDF: failed to allocate memory\n", stderr);
  115. - free(user);
  116. fclose(logfp);
  117. return -2;
  118. }
  119. @@ -463,7 +455,6 @@
  120. }
  121. mode=(0666&~conf.userumask);
  122. }
  123. - free(user);
  124. if (prepareuser(passwd, dirname)) return -2;
  125. log_event(CPDEBUG, "user information prepared", NULL);
  126. diff -ur cups-pdf-2.0beta2/src/cups-pdf.h cups-pdf-2.0beta2-imp/src/cups-pdf.h
  127. --- cups-pdf-2.0beta2/src/cups-pdf.h 2005-10-23 16:03:20.000000000 +0200
  128. +++ cups-pdf-2.0beta2-imp/src/cups-pdf.h 2005-12-06 19:14:22.000000000 +0100
  129. @@ -40,6 +40,7 @@
  130. struct {
  131. cp_string anondirname;
  132. cp_string anonuser;
  133. + cp_string forceduser;
  134. cp_string ghostscript;
  135. cp_string gscall;
  136. cp_string grp;
  137. @@ -63,6 +64,7 @@
  138. void _set_defaults() {
  139. snprintf(conf.anondirname,BUFSIZE,"%s","/var/spool/cups-pdf/ANONYMOUS");
  140. snprintf(conf.anonuser,BUFSIZE,"%s","nobody");
  141. + snprintf(conf.forceduser,BUFSIZE,"%s","");
  142. snprintf(conf.ghostscript,BUFSIZE,"/usr/bin/gs");
  143. snprintf(conf.gscall,BUFSIZE,"%s","%s -q -dCompatibilityLevel=%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=\"%s\" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c save pop -f %s");
  144. snprintf(conf.grp,BUFSIZE,"%s","lp");
  145. @@ -91,6 +93,8 @@
  146. strncpy(conf.anondirname,value,BUFSIZE);
  147. else if (!strcmp("AnonUser",key))
  148. strncpy(conf.anonuser,value,BUFSIZE);
  149. + else if (!strcmp("ForcedUser",key))
  150. + strncpy(conf.forceduser,value,BUFSIZE);
  151. else if (!strcmp("GhostScript",key))
  152. strncpy(conf.ghostscript,value,BUFSIZE);
  153. else if (!strcmp("GSCall",key))