Friday, January 28, 2011

CUPS printing compressed

Our apllicatuion send ascii files to the printer. This application indicates with Ctrl-O at starting that the printer should print in 132 columns. I can define a printer pr01 for 80-col printing and pr01-132 for 132 col printing and set the default options accordingly.

lpoptions -p pr01-132 -o cpi=16.6 -o lpi=10

What i'm trying to do is when i send a job the spooler should take pr01-132 when the first char in the file is a Ctrl-O, otherwise pr01.

How can i do this with CUPS ?

  • Your application seems to be confused about whose responsibility it is to determine the rendering of the document. That it precedes the document with an SI character suggests that it is trying to control the rendering itself - [SI] selects condensed mode printing on an IBM DMP (required for 132 column printing in portrait layout). Assuming that your printer is configured and supports IBM emulation, then its simply a matter of setting up a new device in cups using the generic ASCII driver.

    If your printers do not support IBM emulation, and the generic driver does not work as expected, then you'll probably need to strip the [SI] from the file. See this document for details of how to write your own filter. It describes the process for a DVI file - but the principle is the same: first invent a mimetype for your files, say application/vnd.local.proprinter, then set up a recipe for mapping the 'magic bytes' to the mimetype (see /etc/cups/mime.types) then write a script to strip the leading [SI] and convert to ps (man a2ps).

    From symcbean

What are the fieldnames in AD for a user?

Im trying to make a c# app that extracts users from AD. And with the AD im working on there are a lot if wierd names for the fields in a user object.

name = fullname
mail = email
telephoneNumber = phone number 

(yeah, not much wierdness yet... but:)

sn = surename
co = country
l = city
st = state

So my question is there a list of the fieldnames that i can extract for a user or are they setup by the administrator (ifso i have to ask him for his crazy keywords)?

  • AD is basically a customized-for-windows LDAP server. Is this and this the kind of information you're looking for?

    There are extensions and alterations that can be made to it, such as for integrating Exchange or other services with AD, so you can't necessarily count on every AD environment being exactly the same. But the basic authentication fields shouldn't change.

    You can google for information on importing/exporting bulk information in AD for information about fields and attributes. There are plenty of tools for moving data to and from text files and AD out there.

    Jason94 : Ah, just what I wanted :-)
    Robert Munteanu : @Jason94: Then you should upvote and accept this answer.
    Jason94 : I have acceptet but i have too little street creed around here to up it, sry.
  • I needed similar information not long ago and found this resource quite usefull : link text

    From Kip
  • I personally use ADExplorer (from SysInternals, now owned by Microsoft) and occasionally ADSIEdit for all of my AD property needs. Really helpful when writing code...

    From gWaldo
  • Yes, use an ldap browser is the easiest way. Or lookup the active directory ldap schema

    From Matthew

VMWARE Hosts - Seperate from rest of the network ip sec?

Hi All,

I have a situation with the following setup:

ESX Host - ESX1 Vmware guest os : box1,box2,box3,box4.

There is a special VPN connected to box1 and box3.

All of the guest OS's have full access to the rest of the network.

My aim is to have two groups:

box1 and box3 in one group box2 and box4 in another group.

These should only have access to their own group, and the vpn that comes into box1/2. They should not be able to see the rest of the network.

Due to some port and vm issues, is there a way I can do this from the guest OS's? using internal firewall or ipsec etc?

The aim is to have a duplicate AD environment from our real network, setup on the box3 and box4. Needs to be a duplicate and co-exist as this is dev for some interfaces from other systems, that I cannot pipe of to a dev environment.

A bit of a strange request, but I am hoping someone can poke me in the right direction.

Thanks

  • Think about how you would do this physically - you have a separate physical network with your test servers on, with its own DC on that network. If you needed any kind of communication with your live system, you'd use a firewall/router connected to both networks to control exactly what packets are allowed to pass between the networks.

    You can do this in VMware ESX by creating a new vSwitch for your dev environment. You could create a dedicated firewall VM running something like m0n0wall, and connect that to both the dev vSwitch and your production vSwitch.

    You want to be very careful about letting the DC on the dev system in particular talk to the production network! Set up your firewall rules before connecting the firewall/router to the production network.

    From dunxd

hosting IP change, how much downtime to expect ?

Hi all, i'm moving my hosted site (same host) to a static IP, I understand there will be some downtime due to DNS caching - does anybody have any tips how to minimize this time and to avoid my users seeing "page not found?"

thanks in advance

  • should be minimal. Changing the dns server used in the control panel of your hosting service will take longer, typically 24 hours give or take a bit, but changing the IP pointed to by that dns server should be a very small time, although there might be a delay between entering it and the dns reloading. I think its about 15-30 mins on the DNS service i use.

    dunxd : I've always been warned 48 hours for DNS changes to propogate, and working with offices distributed in many odd locations where DNS servers may be configured in strange ways, this seems about right.
    symcbean : No - it should be the TTL configured on the DNS record + 3 hours
    dunxd : Yes - it *should* be, but depending on where the people you want to visit your site are based, you still want to allow more time. I've seen ISP DNS servers in a few locations completely ignore the TTL specified in the DNS record, and update according to their own schedule. 48 hours seemed a good compromise between what we wanted, and what we got (which was more like two weeks in one location!) Short story - pick a number that seems reasonable, and longer than you'd hope for, and you should be ok...
    From Sirex
  • The best/only way of minimising downtime would be to maintain both IP addresses for 48 hours, preferably on the same server, if your supplier will allow this.

    Sherif Buzz : Thanks for the suggestion, I will check with them.
    From dunxd
  • Tightly control your TTL values before the change. See articles such as:

    You may also want to leave a 302 redirect page on the existing IP address for a week or so.

    From PP
  • I'm assuming that you're referring to The DNS record that resolves to your web site address. If that's the case then here's my answer. It's slightly different from the answers alreay posted, and I'm not trying to start an argument with anyone:

    1. DNS records don't progagate, they cache. DNS is a pull technology, not a push technology.

    2. DNS records should be cached only for the TTL of the record in question.

    3. 99.999% of all DNS clients in the entire world (this includes web browsing clients and other DNS servers) won't have your web site DNS record in their cache. For these clients they'll get the updated information immediately because they'll have to perform a lookup for your web site's DNS record and will find the new information.

    4. The .001% of DNS clients that do have your web site DNS record in their cache will continue to use the old information until the TTL for the DNS record expires, at which time they'll perform a new lookup and get the new information.

    So for all intents and purposes you really don't have much to worry about. My suggestion would be to make sure the TTL on the record is reasonable (say 1 hour to 24 hours) and to change the record at a time you expect to have the least traffic, based on the TTL. For example: If the TTL is 1 hour and your site is not busy from midnight to 8 AM then change it sometime between midnight and 8 AM. If the TTL is 24 hours and the site is not busy on weekends then change it over the weekend, etc., etc.

    Also, as others are sure to point out, some DNS servers don't honor the TTL. There's nothing you can do about that. That's their problem, not yours. If DNS clients of those DNS servers can't access your site because they're caching the old information beyond the life of the TTL then it's their issue to resolve not yours. You can't account for every one off, errant, misconfigured, or otherwise faulty DNS client or server.

    Sirex : +1; this is what i meant by altering which server used vs changing the actual record (but worded better). Doing what the OP is doing should be fine.
    joeqwerty : @Sirex: I agree. Changing name servers may take longer as you stated (If I get what you meant in your answer) but changing the DNS record for the web site should have very little impact.
    From joeqwerty
  • Keep in mind that some browsers maintain their own DNS caches that are separate from the host platform's DNS resolver. See "Client Applications" in this PDF article by Simple Failover.

    Firefox has an addon available called "DNS Cache" which adds network.dnsCacheExpiration=0 to about:config, effectively enabling or disabling the feature on demand.

    For Internet Explorer, see How Internet Explorer uses the cache for DNS host entries.

    From Xhantar

How can I force gnu screen to flush it's logfile?

I am using screen like this:

screen -L -dm -S session1 -c "./game_server -options"

to wrap around game servers. I log their output to a file, and can send them input with:

screen -r session1 -p0 -X "stuff \"this into input^M\""

The timeout between log file flushes can be specified in the configuration file (10 seconds in my case).

The problem I have is that I can't force screen to flush output to the logfile. For example after I send a "status" command to a game server, the game server prints some info, but it takes at least 10 seconds to add that to the log file. I have tried sending:

screen -r session1 -p0 -X "logfile flush 1"

But it doesn't react to that. I've also tried flush 0 with no luck. I wouldn't want to always log with a timeout of 1 second, it's only really needed after receiving a command. Note that I'm paranoid about performance here because the session is running a game server after all.

How can I force screen to flush output to the logfile? Is there a way to do what I need (log output to file and send commands to input) other than with screen, maybe with a fifo?

  • Try this:

    screen -r session1 -X colon "logfile flush 1^M"
    

    logfile flush 1 isn't actually a screen command, but colon is. The next thing you pass is the argument to it which has to be quoted and the ^M at the end should actually be a Ctrl-M. Ctrl-V followed by Ctrl-M will generally do the trick for entering an actual Ctrl-M.

    Gipsy King : Thank you very much. Also, I was having problems with Ctrl-V Ctrl-M: it did print ^M in the command line, but then simply printed ^M in the screen window. Might have been the quotes. I ended up using this: screen ... -X stuff "$(printf '%b' 'this into input\015')".
    From mark

Using Active Directory authentication with Samba on Ubuntu 9.10 server 64bit

I have an Ubuntu server joined to our office Active Directory domain (Windows 2008) and it all seems happy. I can ssh to the server using my AD credentials and home directories get created and all is fine.

I want to share a directory out from the server and use AD authentication (security = ads) using Samba.

Following the docs, I got to the situation where I can see the share externally, but my AD credentials do not allow me to connect.

Using the same credentials from the server itself works using mount.cifs -- i.e. I can mount \\localhost\share using domain\me

I cannot get it to work from my desktop using my AD credentials, but I can connect using a set of Unix credentials so it seems that Samba can't resolve my AD details, but that confuses me as I can use AD credentials using mount.cifs as stated above.

Is there something about the way Windows provides the credentials that Samba doesn't understand?

Bonus question:

I haven't set up Subversion on the server yet, but when I do will I be able to use AD credentials to authenticate on HTTP access via Apache?

  • The first thing you should do is check your Samba logs, and if need be turn up the log level: http://oreilly.com/catalog/samba/chapter/book/ch04_08.html

    Samba is fairly verbose and helpful when it comes to explaining why a connection was not permitted. You'll no doubt find some very good hints as to what your problem is in the logs. e.g. Find the original error message and do a Google search.

    nickd : I had unwound some of my settings and now I am having trouble even getting as far as I was. I can still ssh to the box, but I can't mount.cifs anymore. Samba log file is saying `create_connection_server_info failed: NT_STATUS_ACCESS_DENIED`
    David Harrison : If you are seeking an answer you need to post more information. e.g. Your Samba configuration and the error logs you are seeing. Turning up the log level in Samba will display the source of the NT_STATUS_ACCESS_DENIED message which you can then Google, post here, or on the Samba mailing list.
  • When connecting from a windows machine to a share like that you need to specify the domain:

    domain\user 
    

    This is only necessary when the windows machine is not joined to the domain.

    With regards to you second question, the answer is yes. Example config:

    <Location /svn>
    DAV svn
    SVNParentPath /path/to/svn
    AuthType Basic
    AuthName "SVN"
    AuthBasicProvider ldap
    AuthLDAPBindDN "CN=BINDUSER,CN=Users,DC=domain,DC=com"
    AuthLDAPBindPassword BINDPASSWORD
    AuthLDAPURL "ldap://ldap.server.hostname:389/OU=Users,DC=company,DC=com?sAMAccountName?sub?(objectClass=*)"
    AuthzLDAPAuthoritative off
    Require valid-user
    

    It's important to note that AD will not allow anonymous binds so you'll need to create a user to bind with. Something like svnauth, and replace BINDUSER/BINDPASSORD above.

    From sideh

Good rsync-with-version-history solution for mission-critical remote backups on Windows?

I need to back up some huge files (100GB) and a zillion little ones (2,000,000 x 50k) over the internet via SSL, from one Windows Server 2008 box to another.

What I want is to have the directory structure on the backup server mirror the production server -- but with a version history. rsync does the first part, and I know a few products combine rsync with a version history, but I don't know which ones are really ready for prime-time.

My plan was to use Syncrify, but since nobody seems to have any experience with it, I'm looking for other ideas.

  • If you want to backup with a version history as in being able to restore older versions of backed up files, you should probably look at using a versioning system such as git or subversion instead of a copy system like rsync. Less recommended alternatives would be to manage your own deltas with something like incremental tar files.

    If I misunderstood what you want for "version history", please clarify your question, but rsync itself is not a tool equipped to keep a history of either it's own actions over time or versions of files as they change through time. It is just a copy/synchronization tool. A very good one at that, but a very specific use tool.

    Edit: Another tool that might suit your needs is rsnapshot, which uses rsync as a copy tool but keeps track of multiple versions so that you can backtrack to older "snapshots".

    Jesse : Caleb, thanks for the version-control suggestion. AFAIK, git and svn don't have the bandwidth-saving delta storage that rsync does. rsnapshot would be perfect... if it ran on Windows.
    From Caleb
  • Syncrify is good and should work. We use it to backup our web server and it works fine. However, I have not te

    Jesse : Danny, can you tell me more about what you're backing up?
    From Danny