The Northward Equinox is
upon us again in 2 days on March 20th, 11:02 AM UT. This is also called the
March Equinox or for a northern hemispherer the Spring Equinox. Have fun
with this information!
In 1999 or so I switched globalserve.net's relay mail servers to postfix,
taking the load off sendmail. Today I switched my main mail servers to
OpenSMTPD, ending 14 years of loving
postfix. I still run postfix at work but in time we'll be able to switch
it as well, I hope.
I have made a libssh program to sftp a file from standard input to a file
on an sftp site. I use strato hidrive cloud storage for my backups and
that is what I use this file for. I pipe it through openssl and another
one time pad program to make sure strato can't look at my stuff. I want
to share the code, here it is:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define FTPUSER "secret"
#define FTPPASS "extrasecret"
int
main(int argc, char *argv[])
{
ssh_session sess;
sftp_session sftp;
sftp_file file;
char *user = FTPUSER;
char *pass = FTPPASS;
char buf[512];
u_char md5buf[16];
char timebuf[32];
u_char *hash = NULL;
int ch, fd, rc;
int len;
int state, hlen;
int checksum = 0;
int nwritten;
struct tm *tm;
MD5_CTX ctx;
time_t now;
while ((ch = getopt(argc, argv, "mp:u:")) != -1) {
switch (ch) {
case 'm':
checksum = 1;
break;
case 'u':
user = optarg;
break;
case 'p':
pass = optarg;
break;
}
}
argc -= optind;
argv += optind;
if (argv[0] == NULL || argv[1] == NULL) {
perror("args -> IP file");
exit(1);
}
/* log in here */
if ((sess = ssh_new()) == NULL) {
perror("ssh_new");
exit(1);
}
ssh_options_set(sess, SSH_OPTIONS_HOST, argv[0]);
if ((rc = ssh_connect(sess)) != SSH_OK) {
fprintf(stderr, "error connecting to %s: %s\n", argv[0],
ssh_get_error(sess));
ssh_free(sess);
exit(1);
}
state = ssh_is_server_known(sess);
hlen = ssh_get_pubkey_hash(sess, &hash);
if (state != SSH_SERVER_KNOWN_OK) {
fprintf(stderr, "something was wrong with the session "
"state, to be sure I'll just exit here..\n");
ssh_disconnect(sess);
ssh_free(sess);
exit(1);
}
if ((rc = ssh_userauth_password(sess, user, pass)) != SSH_AUTH_SUCCESS) {
fprintf(stderr, "error authenticating...\n");
ssh_disconnect(sess);
ssh_free(sess);
exit(1);
}
if ((sftp = sftp_new(sess)) == NULL) {
fprintf(stderr, "Error allocating SFTP session: %s\n",
ssh_get_error(sess));
ssh_disconnect(sess);
ssh_free(sess);
exit(1);
}
if ((rc = sftp_init(sftp)) != SSH_OK) {
fprintf(stderr, "Error initializing SFTP session: %s\n",
sftp_get_error(sftp));
sftp_free(sftp);
ssh_disconnect(sess);
ssh_free(sess);
exit(1);
}
snprintf(buf, sizeof(buf), "/home/pjp/%s", argv[1]);
file = sftp_open(sftp, buf, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (file == NULL) {
fprintf(stderr, "can't open file for writing: %s\n",
ssh_get_error(sess));
sftp_free(sftp);
ssh_disconnect(sess);
ssh_free(sess);
exit(1);
}
if (checksum) {
(void)MD5_Init(&ctx);
}
while ((len = read(STDIN_FILENO, &buf, sizeof(buf))) > 0) {
if (checksum) {
(void)MD5_Update(&ctx, buf, len);
}
nwritten = sftp_write(file, buf, len);
if (nwritten != len) {
fprintf(stderr, "can't write/append data to file: %s\n",
ssh_get_error(sess));
sftp_free(sftp);
ssh_disconnect(sess);
ssh_free(sess);
exit(1);
}
}
rc = sftp_close(file);
if (rc != SSH_OK) {
fprintf(stderr, "can't close the written file: %s\n",
ssh_get_error(sess));
}
sftp_free(sftp);
/* ssh cleanup */
ssh_disconnect(sess);
ssh_free(sess);
/* end checksumming */
if (checksum) {
(void)MD5_Final((u_char *)md5buf, &ctx);
fd = open("/root/history.md5", O_WRONLY | O_CREAT| O_APPEND, 0600);
if (fd < 0) {
perror("open");
exit(1);
}
now = time(NULL);
tm = localtime(&now);
strftime(timebuf, sizeof(timebuf), "%F", tm);
snprintf(buf, sizeof(buf),
"%s %s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
timebuf, argv[1],
md5buf[0] & 0xff, md5buf[1] & 0xff, md5buf[2] & 0xff,
md5buf[3] & 0xff, md5buf[4] & 0xff, md5buf[5] & 0xff,
md5buf[6] & 0xff, md5buf[7] & 0xff, md5buf[8] & 0xff,
md5buf[9] & 0xff, md5buf[10] & 0xff, md5buf[11] & 0xff,
md5buf[12] & 0xff, md5buf[13] & 0xff, md5buf[14] & 0xff,
md5buf[15] & 0xff);
write(fd, buf, strlen(buf));
close(fd);
}
exit (0);
}
The program has hardcoded passwords, not optimal but it works. Also the
key must match or it bails immediately (or should). Have fun with this!
0 comments
Be sure to check out SVP Radio on Wednesday
March 6th, starting at 6PM Eastern
North American time. We have made a few changes which allow listening through
the browser, and it may even work on an iPhone.
I have made a video entry introducing my blog. I recorded off the webcam
and converted the .avi to theora with ffmpeg2theora. A Firefox browser
should be able to run this. It works on my OpenBSD box.
Recently the news of Marissa Mayer (CEO of Yahoo) pulling all teleworkers at
their organization back to their own corporate headquarters, struck me. I
found it as wrong but discussion with a few californians on IRC they were
of the perception that workers at yahoo who teleworked from home got a free
paid vacation. BBC
made an article about it.
I work from home and work is 6 timezones away in another hemisphere. This
comes to my benefit though because I'M able to do technical maintenance on
the computers at 4AM when it's 10AM here. This allows me to upkeep a "day"
lifestyle, none of that 12 hour-days insanity that I did in my 20's. In
fact everything is a lot more relaxed in operations so that we can draw
benefits from me working from 6 timezones away.
Sure there is days I wished I could have been a bit more productive or had
a buddy help me with something, but I believe my time is very productive.
Another add-on to that is that I only work 30 hours a week and cannot do
more because of illness (my doctor recommends this much). However working
from home requires discipline. That's why I have an "office", a dedicated
room in the apartment where I do my daily/eveningly tasks. This apartment
is relatively new and I did some work out of a 1-room apartment for a few
months, I'm glad that is behind me.
So I would say to Mrs. Mayer "you're not being fair to teleworkers". As
every situation is different, and teleworkers have a strange but effective
benefit.
FreeBSD Foundation gets 250 dollars in memory of Dan Moschuk, who was a FreeBSD committer and a friend of mine.
And another friend of mine gets 50 dollars or so for hosting SVPradio.com
online radio stream. It's our 100th show on March 6th, 2013, and I promised
I'd get him a bit of money in appreciation.
.
So I'm really into this by now, when there is a project that I see sense in
giving money I give them money :P. Also one has to understand that I use
OpenBSD and FreeBSD at work, so these projects help me make my money so
why shouldn't I share a little of that? I think it's right and justified.
0 comments
I did not know this. And I noticed it today with packet dumping on my firewall.
In german I would say "Das ist eine Sauerei!". Anyhow I googled a little and
found this
helpful blog. Basically what DNS prefetching is, is that when you visit a
website and that website happen to have the link http://www.centroid.eu on it
the browser would conduct a lookup of this Internet name and caches it. It
could speed up things but I think it's a privacy invasion on my part because
I look at an offline wikipedia here and the citations show someone sniffing
outside my link what page I'm looking up by correlating. Yes I'm paranoid
and it's not their business.
The fire curses client (firec) is what I did while I was at my parents after
the apartment fire. It allows me to IRC in a semi-windowed environment.
Browse and download the source here: