Creating signed rpm in Linux

Recently someone came up to me with this query – How to generate a signed rpm in linux?

After building your RPM package, it’s a good idea to sign the package with your own GPG Key to make sure the package is authentic.  Well, before you could sign an rpm package at build time, you must create a gpg key and a passphrase
Below are steps for the same –
  1. Generate a signature key – 
———–clip———
[xxx@yyy]$ gpg –gen-key
gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
Please select what kind of key you want:
   (1) DSA and Elgamal (default)
   (2) DSA (sign only)
   (5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 2048
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
    “Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>”
Real name: john
Email address: john@testmail.com
Comment: No Comments
You selected this USER-ID:
    “john(No Comments) <john@testmail.com>”
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
++++++++++++++++++++.++++++++++++++++++++++++++++++…++++++++++.++++++++++++++++++++++++++++++.+++++++++++++++.++++++++++++++++++++++++++++++………………………………………………………>.+++++…………………………………………………………….+++++
Not enough random bytes available.  Please do some other work to give
the OS a chance to collect more entropy! (Need 283 more bytes)
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++.+++++++++++++++++++++++++++++++++++….++++++++++.+++++.+++++++++++++++++++++++++..+++++>+++++..+++++>..+++++…….>+++++………………………………………………………………………………………….+++++^^^
gpg: key DB17E9EE marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   1024D/DB17E9EE 2012-07-19
      Key fingerprint = 22E1 4A80 9899 0A27 4BD8  3200 37C4 857A DB17 E9EE
uid                  john(No Comments) <john@testmail.com>
sub   2048g/E7FFDEEF 2012-07-19
———–clap———
2.  Confirm that the above created signatures are present in the signature repository –
———–clip———-
[xxx@yyy]$ gpg –list-sigs
/home/xxx/.gnupg/pubring.gpg
———————————
pub   1024D/DB17E9EE 2012-07-19
uid                  xxx(No Comments) <john@testmail.com>
sig 3        DB17E9EE 2012-07-19  john(No Comments) <john@testmail.com>
sub   2048g/E7FFDEEF 2012-07-19
sig          DB17E9EE 2012-07-19  john(No Comments) <john@testmail.com>
———–clap———-
3. Create a file “.rpmmacros” in your home directory and add the below lines to the same ( I’ve given “john” to “%_gpg_name” as this is the real name of the signature owner that i have provided in Step 1) –
——-clip——-
%_signature gpg
%_gpg_name john
%_gpgbin /usr/bin/gpg
——-clap——-
4. Now, you’re all  ready to sign your RPM package –
——-clip——-
[xxx@yyy]$ rpm –addsign XXX-YYY-ZZZ-2.0-5.WW.i386.rpm                               // rpm name is just an example
Enter pass phrase:                   // Here provide the pass phrase as "test" because this is what I have provided 
                                     // for the signature owner "John" in Step 1
Pass phrase is good.
XXX-YYY-ZZZ-2.0-5.WW.i386.rpm:
——-clap——-
You can verify your signature on the RPM  using the command:

rpm –checksig XXX-YYY-ZZZ-2.0-5.WW.i386.rpm     // rpm name is just an example

WebSphere AppServer 6.1 MQ JMS log enabling

Static trace enabling:

1. Log on to the Administrative Console.
2. In the left panel, expand Troubleshooting. Click on “Logs and Trace”.
3. Select the application server that is to be traced. Then on the next page click on the “Diagnostic Trace” link.
4. Select the Configuration tab.
5. Select the “Enable Log” property, if already not selected.
6. Under the “Trace Output”, select the File radio button, if already not selected. Set the Maximum file size to 100 MB and Increase the Maximum number of historical files to 10.
7. To ensure you capture full data flows, select Advanced for the Trace Output Format.
8. Click on the “Change Log Detail Levels” under Additional Properties on the right side panel.
9. Under the Configuration tab, enter the following string :

*=info:JMSServer=all:Messaging=all:JMS_WASTraceAdapter=all:com.ibm.mq.*=all:jmsApi=all

10. To gather transaction and connection API trace, append the following string :

For Connection: ConnLeakLogic=all:WAS.j2c=all
For Transaction: Transaction=all

11. Click OK and Save. your configuration.  Select Synchronize changes with Nodes option.Then restart the Application server.

Dynamic trace enabling:

1. Log on to the administrative console.
2. In the left panel, expand Troubleshooting and click on Logs and Trace.
3. Select the application server to be traced, and than on the next page click the Diagnostic Trace link.
4. Select the Runtime tab (Server should be up and running for this tab to show up).
5. Under Trace Output, select File and type a File name (if you do not specify path, but just the file name, then the default location of the file is under the application server profile directory). Set the Maximum File size to 100Mb and Maximum Number of historical files to 10.
Important: Do not select Save Runtime Changes to Configuration as well if you do not want this setting to become permanent.
6. On same panel click on Change Log Detail Levels under Additional Properties on right side panel.
7. Select the Runtime tab.
8. Enter the following trace string :

*=info:JMSApi=all:JMSServer=all:Messaging=all:JMS_WASTraceAdapter=all:com.ibm.mq.*=all:jmsApi=all

9. To gather transaction and connection API trace, append the following string:

For Connection: ConnLeakLogic=all:WAS.j2c=all
For Transaction: Transaction=all

10. Click Apply and OK. Then Save your configuration.  Select Synchronize changes with Nodes option.

Using the rollup feature of Selenium

Recently someone had put forward a doubt on the usage of rollup feature in Selenium.

Rollup, in Selenium,  is a series of commands with a unique name, and optionally arguments that control the generation of the set of commands. If any one of the rolled-up commands fails, the rollup is considered to have failed. Rollups may also contain nested rollups.

Consider, I want to do below operations in a web browser –

     (a) Login to “http://www.mail.com” URL.
     (b) Type Email
     (c) Type Password
     (d) Click on “Log in”

Logically if you see, all the above 4 different activities are serving  to a single use-case – “do_login”.

Any activity (reading mail, deleting mail, sending mail etc) will need you to first login to your mailbox. So, instead of duplicating the code for “login”  across all your testcases (e.g. reading mail testcase, sending mail testcase, delete mail testcase), you can write only once the testcase code for login and then wrap-up this testcase with a name and call this code with it’s wrapped-up name across all your testcases which needs login to the mailbox as a pre-requisite. This is where the “rollup” feature of Selenium comes into picture.

Have a look at the user-extensions.js (below). You can think of this file as a re-usable library wherein I’ve defined the actual action steps i.e. logging in, typing username, typing password and signing in. I’ve then wrapped up all these actions under “do_login” rollup rule.
I haven’t hardcoded the username and password here as I wanted to read these from the testcase.
var manager = new RollupManager();

manager.addRollupRule({
 name: 'do_login'
 , description: 'log in to mail.com'
 , args: [
 {
 name: 'username'
 , description: 'username'
 }
 , {
 name: 'password'
 , description: 'password'
 }
 ], commandMatchers: [
 ]
 , getExpandedCommands: function(args) {
 var commands = [];

commands.push({
 command: 'open'
 , target: ''
 });
 commands.push({
 command: 'type'
 , target: 'login'
 , value: args.username
 });
 commands.push({
 command: 'type'
 , target: 'password'
 , value: args.password
 });
 commands.push({
 command: 'click'
 , target: 'btnLogin'
 });
 return commands;
 }
});
Now have a look at my actual testcase “rollupExample.html” (below). If you notice, here I’m just calling the rollup rule i.e. “do_login”. Along with it I’m passing the required username and password (sanjit/sanjit). Just a single line of code in my testcase and it takes care of all the login functionality!!!
Now, all you need to do is to make the Selenium core aware of your new user-extensions javascript file and then import the testcase to your selenium IDE and run. Thats all!