diff options
author | Gerald Carter <jerry@samba.org> | 2005-07-15 17:38:55 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:00:07 -0500 |
commit | eb1123e5009c900c0eb741c0a075f918b16bbeab (patch) | |
tree | bb3a26b18f929f9f0ee577255960797e3fd2988e /source3 | |
parent | 6fe54515435e351ba958886cb9a7175c436ef88d (diff) | |
download | samba-eb1123e5009c900c0eb741c0a075f918b16bbeab.tar.gz samba-eb1123e5009c900c0eb741c0a075f918b16bbeab.tar.bz2 samba-eb1123e5009c900c0eb741c0a075f918b16bbeab.zip |
r8506: BUG 2853: don't strip out characters like '$' from printer names
when substituting for the lpq command.
(This used to be commit 2f5de718a98e56fe55d8905b12505dfc3e432544)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util_str.c | 15 | ||||
-rw-r--r-- | source3/printing/printing.c | 24 |
2 files changed, 20 insertions, 19 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 42229f105a..6b91a0d625 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -916,7 +916,7 @@ BOOL string_set(char **dest,const char *src) use of len==0 which was for no length checks to be done. **/ -void string_sub(char *s,const char *pattern, const char *insert, size_t len) +void string_sub2(char *s,const char *pattern, const char *insert, size_t len, BOOL remove_unsafe_characters) { char *p; ssize_t ls,lp,li, i; @@ -951,8 +951,12 @@ void string_sub(char *s,const char *pattern, const char *insert, size_t len) case '%': case '\r': case '\n': - p[i] = '_'; - break; + if ( remove_unsafe_characters ) { + p[i] = '_'; + /* yes this break should be here since we want to + fall throw if not replacing unsafe chars */ + break; + } default: p[i] = insert[i]; } @@ -962,6 +966,11 @@ void string_sub(char *s,const char *pattern, const char *insert, size_t len) } } +void string_sub(char *s,const char *pattern, const char *insert, size_t len) +{ + string_sub2( s, pattern, insert, len, True ); +} + void fstring_sub(char *s,const char *pattern,const char *insert) { string_sub(s, pattern, insert, sizeof(fstring)); diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 0737cf00d1..b49f0716ea 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -43,13 +43,6 @@ static BOOL remove_from_jobs_changed(const char* sharename, uint32 jobid); jobids are assigned when a job starts spooling. */ -struct print_queue_update_context { - char* sharename; - int printing_type; - char* lpqcommand; -}; - - static TDB_CONTEXT *rap_tdb; static uint16 next_rap_jobid; struct rap_jobid_key { @@ -1290,14 +1283,14 @@ this is the receive function of the background lpq updater ****************************************************************************/ static void print_queue_receive(int msg_type, pid_t src, void *buf, size_t msglen) { - struct print_queue_update_context ctx; fstring sharename; pstring lpqcommand; + int printing_type; size_t len; len = tdb_unpack( buf, msglen, "fdP", sharename, - &ctx.printing_type, + &printing_type, lpqcommand ); if ( len == -1 ) { @@ -1305,12 +1298,9 @@ static void print_queue_receive(int msg_type, pid_t src, void *buf, size_t msgle return; } - ctx.sharename = sharename; - ctx.lpqcommand = lpqcommand; - - print_queue_update_with_lock(ctx.sharename, - get_printer_fns_from_type(ctx.printing_type), - ctx.lpqcommand ); + print_queue_update_with_lock(sharename, + get_printer_fns_from_type(printing_type), + lpqcommand ); return; } @@ -1390,8 +1380,10 @@ static void print_queue_update(int snum, BOOL force) fstrcpy( sharename, lp_const_servicename(snum)); + /* don't strip out characters like '$' from the printername */ + pstrcpy( lpqcommand, lp_lpqcommand(snum)); - pstring_sub( lpqcommand, "%p", PRINTERNAME(snum) ); + string_sub2( lpqcommand, "%p", PRINTERNAME(snum), sizeof(lpqcommand), False ); standard_sub_snum( snum, lpqcommand, sizeof(lpqcommand) ); /* |