#include <sys/types.h>
#include <pwd.h>
uid_t getuid_by_loginname(const char *name)
{
struct passwd *pwd;
if(name) {
pwd = getpwnam(name); /* don't free, see getpwnam() for details */
if(pwd)
return pwd->pw_uid;
}
return (uid_t)-1;
}
According to The Directive 2009/24/EC of the European Parliament and of the Council, and Sec.103(f) of the DMCA (17 U.S.C. § 1201 (f)), the reverse engineering act committed to creating these blog posts is considered legal, as this is an original attempt to improve interoperability, and cannot be waived by license agreements.
The views expressed on this blog are my own and do not necessarily reflect the views of my past and present employers.
2014-03-11
C: Get uid by loginname
2014-02-24
JIRA: Get workflows where the post-function refers to a plugin
Note, that JIRAWORKFLOWS.DESCRIPTOR is a valid XML, stored in a CLOB.
As you see, it is using Oracle XDB features, so you might need some rework when using another RDBMS. Also, the cutting out of the DTD is neccessary, as by default, XDB does not allow to load XML-s that have external references (here, the DTD has one).
WITH W_JIRAWORKFLOWS AS
( SELECT WORKFLOWNAME,
XMLTYPE.CREATEXML( REPLACE(DESCRIPTOR,
'<!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow 2.8//EN" "http://www.opensymphony.com/osworkflow/workflow_2_8.dtd">'
)) AS DESCRIPTOR_XML
FROM JIRAWORKFLOWS)
SELECT
WS.NAME AS WF_SCHEME_NAME,
WSE.WORKFLOW AS WF_ENTITY_WORKFLOW,
IT.PNAME AS ISSUETYPE_NAME,
XMLQUERY(
'string-join(distinct-values(//post-functions/function/arg[@name="class.name" and not(starts-with(., "com.atlassian.jira.workflow"))]/text()), ",")'
PASSING DESCRIPTOR_XML
RETURNING CONTENT
).getStringVal() AS PLUGIN_CLASSNAMES
FROM WORKFLOWSCHEMEENTITY WSE
LEFT JOIN ISSUETYPE IT
ON IT.ID = WSE.ISSUETYPE
LEFT JOIN WORKFLOWSCHEME WS
ON WS.ID = WSE.SCHEME
INNER JOIN W_JIRAWORKFLOWS W ON W.WORKFLOWNAME = WSE.WORKFLOW
WHERE XMLEXISTS('//post-functions[function/arg[@name="class.name" and not(starts-with(., "com.atlassian.jira.workflow"))]]'
PASSING BY VALUE DESCRIPTOR_XML);
This way you can see, what kind of Workflows you have, that has post-functions bound to plugins.As you see, it is using Oracle XDB features, so you might need some rework when using another RDBMS. Also, the cutting out of the DTD is neccessary, as by default, XDB does not allow to load XML-s that have external references (here, the DTD has one).
JIRA: List Workflow Schemes, their Workflows, and associated Issue Types
SELECT WS.NAME AS WF_SCHEME_NAME, WSE.WORKFLOW AS WF_ENTITY_WORKFLOW, IT.PNAME AS ISSUETYPE_NAME FROM WORKFLOWSCHEMEENTITY WSE LEFT JOIN ISSUETYPE IT ON IT.ID = WSE.ISSUETYPE LEFT JOIN WORKFLOWSCHEME WS ON WS.ID = WSE.SCHEME;
2014-01-31
JMX connection to a remote HP BSM in VisualVM
- Add Remote Host... and enter your BSM's hostname (this will be the <bsm host>)
- Add JMX Connection...
- To the connection field, enter "<bsm host>:11020" (for BSM, JMX listens on 11020)
- Use security credentials: enter the same that you use at HP Business Service Management Status.
- When VisualVM nags about no SSL, say Yes, if you accept the risks.
Compiling Atlassian JIRA and having hamcrest-all 1.2 maven dependency resolution problem
So you are compiling Atlassian JIRA from source, and the compilation fails with:
Failed to execute goal on project atlassian-secure-random: Could not resolve dependencies for project com.atlassian.security:atlassian-secure-random:jar:3.2.1: Could not find artifact org.hamcrest:hamcrest-all:jar:1.2 in central (https://maven.your-corporation.com/artifactory/repo)
Of course, you started wandering around teh Internet, and was shocked to see, that https://code.google.com/p/hamcrest/ only knows about hamcrest-all 1.1 and 1.3... wtf?!
The missing version is hosted by Atlassian. You should set your stuff up to look up https://maven.atlassian.com/content/groups/public/ also.
Look for Philipp Steinwender's answer at https://answers.atlassian.com/questions/192831/maven-dependency-com-atlassian-jira-plugins for a maven settings.xml fragment.
Failed to execute goal on project atlassian-secure-random: Could not resolve dependencies for project com.atlassian.security:atlassian-secure-random:jar:3.2.1: Could not find artifact org.hamcrest:hamcrest-all:jar:1.2 in central (https://maven.your-corporation.com/artifactory/repo)
Of course, you started wandering around teh Internet, and was shocked to see, that https://code.google.com/p/hamcrest/ only knows about hamcrest-all 1.1 and 1.3... wtf?!
The missing version is hosted by Atlassian. You should set your stuff up to look up https://maven.atlassian.com/content/groups/public/ also.
Look for Philipp Steinwender's answer at https://answers.atlassian.com/questions/192831/maven-dependency-com-atlassian-jira-plugins for a maven settings.xml fragment.
2014-01-21
Quickly generating a password from a dictionary word (easy but not so secure)
So, your requirements are set as:
Examples:
Dog --> D0g0000000000 (D0g and 10 zeroes)
Obama --> Ob4m44444 (Ob4m4 [left the big-o as the uppercase!!!] and 4 fours)
Keyboard --> K3yb04rd0000000000 (K3yb04rd and ten zeroes)
Variations:
- Needs Uppercase letter,
- Needs lowercase letter,
- Needs digit,
- Needs length > 8 characters,
- and there are simple Checks for your Name as a substring,
- Should Not match previous 5..n passwords.
- Grab a dictionary word, at least 7 chars long, which has at least one vowel, and has at least one uppercase letter in it, that feels natural for you. Eg. "Bracket"
- l33t-ize the vowels, except the first letter. Eg. "Bracket" --> "Br4ck3t"
- Find the biggest digit. Zero counts as the biggest. Eg. "Br4ck3t" ==> 4
- Append this digit, `digit` times to the end. Zero means ten. Eg. "Br4ck3t" + 4 --> "Br4ck3t4444"
- Now, you have +uppercase, +lowercase, +digits, +length()>8
Examples:
Dog --> D0g0000000000 (D0g and 10 zeroes)
Obama --> Ob4m44444 (Ob4m4 [left the big-o as the uppercase!!!] and 4 fours)
Keyboard --> K3yb04rd0000000000 (K3yb04rd and ten zeroes)
Variations:
- Full-l33t: also translate s-5, t-| (pipe/bar), small-L-1
- Let zero be zero and it means no new digits at the end
Do not forget, which variation are you using ;-)
It's not the best, but if you still have to change yoour password in every few months, I could go with this. Otherwise, they should introduce smartcards and/or SecurID tokens...
2013-12-18
Sending emails to addresses and subjects in a CSV with a fixed message in a textfile
The following script was generated to notice approvers that an audit initiated the deletion of some users they did not approved (again). The Subject contains the usernames, and the message is a template with some PC blahblah.
The CSV is like "jane.doe@company.com;This is a message in the subject about deleting the account of 'johndoe@company.com'\n". Do NOT put a semicolon into the subject column :-D
IFS sets the Internal Field Separator to semicolon (';'), instead of the default whitespace. This way the array generator/tokenizer is dead simple in the next line.
$1 is the CSV file, read into $p line-by-line.
$2 is the fixed message piped into mail.
#!/bin/bash
if [ $# -lt 2 ]; then
echo "No arguments passed! I need a 'mailaddr;subject' .csv and a txt containing the fixed message."
echo "csvmailer.sh addresses.csv message.txt"
exit 1
fi
while read p; do
IFS=';'
TOKENS=($p)
EMAIL=${TOKENS[0]}
SUBJ=${TOKENS[1]}
IFS=' '
mail -s "$SUBJ" "$EMAIL" < $2
done < $1
The CSV is like "jane.doe@company.com;This is a message in the subject about deleting the account of 'johndoe@company.com'\n". Do NOT put a semicolon into the subject column :-D
IFS sets the Internal Field Separator to semicolon (';'), instead of the default whitespace. This way the array generator/tokenizer is dead simple in the next line.
$1 is the CSV file, read into $p line-by-line.
$2 is the fixed message piped into mail.
2013-12-17
Battlefield 2 Piloting with mouse - tip of the day
Assign "pitch up" ("pitch+") to a key on your keyboard (like spacebar, it's unused by default in jets), so you don't have to destroy your mouse while pulling up ;-)
Thanks, Andris!
Thanks, Andris!
2013-12-15
Cisco VPN vs. Linux, KDE
So you have a Cisco proprietary PCF file, and you want to use it in your KDE, but the Network Manager's VPN Import says it cannot do it?
Here is what to do:
# apt-get install network-manager-vpnc
(This should also install vpnc if you haven't had it already.) Now, try importing the PCF file again.
Many thanks to: http://thomas.zumbrunn.name/blog/2013/04/04/479/
Here is what to do:
# apt-get install network-manager-vpnc
(This should also install vpnc if you haven't had it already.) Now, try importing the PCF file again.
Many thanks to: http://thomas.zumbrunn.name/blog/2013/04/04/479/
2013-12-05
Linux: Send files in e-mail from console
So I wanted to send some files, but my mailx package did not have support for the famous -a parameter.
#!/bin/bash
function create_attachment_block()
{
echo -ne "--$BOUNDARY\r\nContent-Transfer-Encoding: base64\r\n"
echo -ne "Content-Type: $(file -bi "$1"); name=\"$1\"\r\n"
echo -ne "Content-Disposition: attachment; filename=\"$1\"\r\n\r\n$(base64 -w 0 "$1")\r\n\r\n"
}
if [ $# -lt 2 ]; then
echo No files specified...
exit 1;
fi
BOUNDARY="==combine-autogun==_$(date +%Y%m%d%H%M%S)_$$_=="
BODY=""
for a in "$@"
do
if [ -s "$a" -a -f "$a" -a -r "$a" ]; then
BODY="$BODY""`create_attachment_block "$a"`"
fi
done
/usr/sbin/sendmail -oi -t << COMPLEX_MAIL
To: $1
Subject: Please see files attached
MIME-Version: 1.0
User-Agent: $0
Content-Type: multipart/mixed; boundary="$BOUNDARY"
$BODY
--${BOUNDARY}--
COMPLEX_MAIL
Subscribe to:
Posts
(
Atom
)