Hello community, here is the log from the commit of package smugbatch for openSUSE:Factory checked in at Thu Aug 4 09:46:48 CEST 2011. -------- --- smugbatch/smugbatch.changes 2010-12-11 17:33:54.000000000 +0100 +++ /mounts/work_src_done/STABLE/smugbatch/smugbatch.changes 2011-07-29 15:57:57.000000000 +0200 @@ -1,0 +2,7 @@ +Fri Jul 29 13:54:51 UTC 2011 - aj@suse.de + +- Update to v006: + * includes smugbatch-api1.2.2.patch to support smugmug 1.2.2 api + * bugfixes + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- smugbatch-005.tar.bz2 smugbatch-api1.2.2.patch New: ---- smugbatch-006.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ smugbatch.spec ++++++ --- /var/tmp/diff_new_pack.ue2JEf/_old 2011-08-04 09:46:20.000000000 +0200 +++ /var/tmp/diff_new_pack.ue2JEf/_new 2011-08-04 09:46:20.000000000 +0200 @@ -24,13 +24,12 @@ %else BuildRequires: curl-devel %endif -Version: 005 +Version: 006 Release: 1 License: GPLv2 Summary: Tools for smugmug.com Url: http://github.com/gregkh/smugbatch/tree/master -Source: %{name}-%{version}.tar.bz2 -Patch1: smugbatch-api1.2.2.patch +Source: http://www.kernel.org/pub/linux/kernel/people/gregkh/smugbatch/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -42,7 +41,6 @@ %prep %setup -q -%patch1 -p1 %build make V=1 CFLAGS="%{optflags}" ++++++ smugbatch-005.tar.bz2 -> smugbatch-006.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smugbatch-005/ChangeLog new/smugbatch-006/ChangeLog --- old/smugbatch-005/ChangeLog 2008-08-19 21:46:03.000000000 +0200 +++ new/smugbatch-006/ChangeLog 2011-07-19 20:16:59.000000000 +0200 @@ -1,3 +1,16 @@ +Summary of changes from v005 to v006 +============================================ + +Andreas Jaeger (2): + Get smugbatch to work properly with the 1.2.2 API + Use the 1.2.2 api properly + +Jonathan Neuschäfer (4): + HACKING: fix a typo ("smubatch") + session_alloc: fix a null-pointer dereference + smug_core: fix a memory leak in get_string_from_stdin + fix memory leaks found by cppcheck + Summary of changes from v004 to v005 ============================================ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smugbatch-005/HACKING new/smugbatch-006/HACKING --- old/smugbatch-005/HACKING 2008-08-19 21:46:03.000000000 +0200 +++ new/smugbatch-006/HACKING 2011-07-19 20:16:59.000000000 +0200 @@ -1,7 +1,7 @@ Patches are gladly accepted for smugbatch code, please send them to greg@kroah.com, or you can use github to send a pull request. -The code tree for smubatch is located at: +The code tree for smugbatch is located at: http://github.com/gregkh/smugbatch and can be cloned using git from: git://github.com/gregkh/smugbatch.git @@ -28,18 +28,3 @@ It is safe to ignore the valgrind errors in the curl and ssl libraries, we can't do anything about those at this time. - -Basic usage with github: -* create a fork of gregkh/smugbatch at github.com -* Check it out locally: git clone git@github.com:ajaeger/smugbatch.git -* switch to the directory: cd smugbatch/ -* add Greg's git as remote repository: - git remote add smugcore git://github.com/gregkh/smugbatch.git -* Fetch it: - git fetch smugcore -* This will create a branch, so merge it back: - git checkout master - git merge smugcore/master -* Sync merge back: - git commit -a -m "Sync to fork master" - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smugbatch-005/Makefile new/smugbatch-006/Makefile --- old/smugbatch-005/Makefile 2008-08-19 21:46:03.000000000 +0200 +++ new/smugbatch-006/Makefile 2011-07-19 20:16:59.000000000 +0200 @@ -16,7 +16,7 @@ # # -VERSION = 005 +VERSION = 006 PROGRAM = smugup smugls smugdown @@ -126,8 +126,8 @@ git commit -a -m "release $(VERSION)" cat .git/refs/heads/master > .git/refs/tags/$(VERSION) @ echo - git-archive --format=tar --prefix=smugbatch-$(VERSION)/ HEAD | gzip -9v > smugbatch-$(VERSION).tar.gz - git-archive --format=tar --prefix=smugbatch-$(VERSION)/ HEAD | bzip2 -9v > smugbatch-$(VERSION).tar.bz2 + git archive --format=tar --prefix=smugbatch-$(VERSION)/ HEAD | gzip -9v > smugbatch-$(VERSION).tar.gz + git archive --format=tar --prefix=smugbatch-$(VERSION)/ HEAD | bzip2 -9v > smugbatch-$(VERSION).tar.bz2 .PHONY: release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smugbatch-005/RELEASE-NOTES new/smugbatch-006/RELEASE-NOTES --- old/smugbatch-005/RELEASE-NOTES 2008-08-19 21:46:03.000000000 +0200 +++ new/smugbatch-006/RELEASE-NOTES 2011-07-19 20:16:59.000000000 +0200 @@ -1,3 +1,8 @@ +smugbatch 006 +============= +1.2.2 api updates, thanks to Andreas Jaeger +minor bugfixes on error paths thanks to Jonathan Neuschäfer + smugbatch 005 ============= Ability to create the album to upload to if it is not already present diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smugbatch-005/smug.h new/smugbatch-006/smug.h --- old/smugbatch-005/smug.h 2008-08-19 21:46:03.000000000 +0200 +++ new/smugbatch-006/smug.h 2011-07-19 20:16:59.000000000 +0200 @@ -62,6 +62,7 @@ char *password; char *email; char *session_id; + char *su_cookie; struct list_head albums; struct list_head files_upload; struct list_head files_download; @@ -126,7 +127,7 @@ extern int smug_get_albums(struct session *session); extern int smug_read_images(struct session *session, struct album *album); extern void smug_parse_configfile(struct session *session); -extern int smug_download(struct filename *filename); +extern int smug_download(struct session *session, struct filename *filename); extern int debug; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smugbatch-005/smug_core.c new/smugbatch-006/smug_core.c --- old/smugbatch-005/smug_core.c 2008-08-19 21:46:03.000000000 +0200 +++ new/smugbatch-006/smug_core.c 2011-07-19 20:16:59.000000000 +0200 @@ -41,31 +41,31 @@ static char *session_id_tag = "Session id"; static char *smugmug_album_list_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.albums.get" "&SessionID=%s&APIKey=%s"; static char *smugmug_album_create_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.albums.create" "&SessionID=%s&Title=%s&CategoryID=%s&AlbumTemplateID=%s"; static char *smugmug_category_list_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.categories.get" "&SessionID=%s"; static char *smugmug_quicksettings_list_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.albumtemplates.get" "&SessionID=%s"; static char *smugmug_login_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.login.withPassword" "&EmailAddress=%s&Password=%s&APIKey=%s"; static char *smugmug_logout_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.logout" "&SessionID=%s&APIKey=%s"; static char *smugmug_image_list_url = - "https://api.smugmug.com/hack/rest/1.2.0/?" + "https://secure.smugmug.com/services/api/rest/1.2.2/?" "method=smugmug.images.get" "&SessionID=%s&Heavy=1&AlbumID=%s&AlbumKey=%s"; static char *smugmug_upload_url = @@ -89,6 +89,47 @@ return curl; } +static char *get_su_cookie(CURL *curl) +{ + CURLcode res; + struct curl_slist *cookies; + struct curl_slist *nc; + char *cookie = NULL; + + res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies); + if (res != CURLE_OK) { + fprintf(stderr, "Curl curl_easy_getinfo failed: %s\n", + curl_easy_strerror(res)); + exit(1); + } + nc = cookies; + while (nc) { + char domain[50], p1[50], p2[50], p3[50], name[50], value[50]; + long unsigned int t; + int res; + + /* #HttpOnly_.smugmug.com\tTRUE\t/\tFALSE\t0\tSMSESS\t99363be4c3ceb3f153f875216539524a */ + res = + sscanf(nc->data, "%s\t%s\t%s\t%s\t%lu\t%s\t%s", domain, p1, + p2, p3, &t, name, value); + if (res == 7 && strcmp(name, "_su") == 0) { + cookie = valloc(strlen(value) + 1 + 4); + sprintf(cookie, "_su=%s", value); + } + nc = nc->next; + } + curl_slist_free_all(cookies); + return cookie; +} + +static void curl_set_cookie(CURL *curl, const char *cookie) +{ + if (cookie == NULL) + return; + + curl_easy_setopt(curl, CURLOPT_COOKIE, cookie); +} + char *my_basename(char *name) { @@ -120,8 +161,10 @@ if (!string) return NULL; - if (!fgets(string, 99, stdin)) + if (!fgets(string, 99, stdin)) { + free(string); return NULL; + } temp = strchr(string, '\n'); *temp = '\0'; return string; @@ -254,6 +297,7 @@ session = zalloc(sizeof(*session)); if (!session) return NULL; + session->su_cookie = NULL; INIT_LIST_HEAD(&session->albums); INIT_LIST_HEAD(&session->files_upload); INIT_LIST_HEAD(&session->files_download); @@ -497,27 +541,37 @@ return -ENOMEM; progress = zalloc(sizeof(*progress)); - if (!progress) + if (!progress) { + smug_curl_buffer_free(buffer); return -ENOMEM; + } progress->filename = filename->basename; progress->upload = 1; progress->position = position; progress->total = total; curl = curl_init(); - if (!curl) + if (!curl) { + free(progress); + smug_curl_buffer_free(buffer); return -EINVAL; + } file_handle = open(filename->filename, O_RDONLY); fstat(file_handle, &file_info); close(file_handle); fd = fopen(filename->filename, "rb"); - if (!fd) + if (!fd) { + curl_easy_cleanup(curl); + free(progress); + smug_curl_buffer_free(buffer); return -EINVAL; + } dbg("%s is %d bytes big\n", filename->filename, (int)file_info.st_size); sprintf(url, smugmug_upload_url, filename->basename); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); @@ -532,7 +586,7 @@ sprintf(buf, "Content-MD5: %s", md5_string); dbg("%s\n", buf); headers = curl_slist_append(headers, buf); - headers = curl_slist_append(headers, "X-Smug-Version: 1.2.0"); + headers = curl_slist_append(headers, "X-Smug-Version: 1.2.2"); headers = curl_slist_append(headers, "X-Smug-ResponseType: REST"); sprintf(buf, "X-Smug-SessionID: %s", session->session_id); dbg("%s\n", buf); @@ -669,7 +723,7 @@ dbg("url = %s\n", url); curl_easy_setopt(curl, CURLOPT_URL, url); - + curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* log into smugmug */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -678,7 +732,7 @@ printf("error(%d) trying to login\n", res); return -EINVAL; } - + session->su_cookie = get_su_cookie(curl); char *rsp_stat = find_value(curl_buf->data, "rsp stat", NULL); if (!rsp_stat) return -EINVAL; @@ -715,18 +769,23 @@ return -ENOMEM; curl = curl_init(); - if (!curl) + if (!curl) { + smug_curl_buffer_free(curl_buf); return -EINVAL; + } sprintf(url, smugmug_logout_url, session->session_id, api_key); dbg("url = %s\n", url); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); res = curl_easy_perform(curl); if (res) { fprintf(stderr, "error(%d) trying to logout\n", res); + curl_easy_cleanup(curl); + smug_curl_buffer_free(curl_buf); return -EINVAL; } @@ -751,11 +810,15 @@ return -ENOMEM; curl = curl_init(); - if (!curl) + if (!curl) { + smug_curl_buffer_free(curl_buf); return -EINVAL; + } sprintf(url, smugmug_album_list_url, session->session_id, api_key); dbg("url = %s\n", url); + + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -763,12 +826,16 @@ if (res) { fprintf(stderr, "error(%d) trying to read list of albums\n", res); + curl_easy_cleanup(curl); + smug_curl_buffer_free(curl_buf); return -EINVAL; } retval = get_albums(curl_buf, session); if (retval) { fprintf(stderr, "error parsing albums\n"); + curl_easy_cleanup(curl); + smug_curl_buffer_free(curl_buf); return -EINVAL; } @@ -803,6 +870,7 @@ sprintf(url, smugmug_quicksettings_list_url, session->session_id); dbg("url = %s\n", url); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -880,6 +948,7 @@ sprintf(url, smugmug_category_list_url, session->session_id); dbg("url = %s\n", url); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -975,6 +1044,7 @@ free(category_id); free(qs_id); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -1046,12 +1116,16 @@ return -ENOMEM; curl = curl_init(); - if (!curl) + if (!curl) { + smug_curl_buffer_free(curl_buf); return -EINVAL; + } sprintf(url, smugmug_image_list_url, session->session_id, album->id, album->key); dbg("url = %s\n", url); + + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); @@ -1059,12 +1133,16 @@ if (res) { fprintf(stderr, "error(%d) trying to read list of albums\n", res); + curl_easy_cleanup(curl); + smug_curl_buffer_free(curl_buf); return -EINVAL; } retval = get_images(curl_buf, album); if (retval) { fprintf(stderr, "error parsing albums\n"); + curl_easy_cleanup(curl); + smug_curl_buffer_free(curl_buf); return -EINVAL; } @@ -1073,7 +1151,7 @@ return 0; } -int smug_download(struct filename *filename) +int smug_download(struct session *session, struct filename *filename) { struct smug_curl_buffer *curl_buf; CURL *curl = NULL; @@ -1091,8 +1169,10 @@ dbg("1\n"); progress = zalloc(sizeof(*progress)); - if (!progress) + if (!progress) { + smug_curl_buffer_free(curl_buf); return -ENOMEM; + } progress->filename = filename->basename; progress->upload = 0; progress->position = 1; /* FIXME */ @@ -1100,11 +1180,15 @@ dbg("2\n"); curl = curl_init(); - if (!curl) + if (!curl) { + free(progress); + smug_curl_buffer_free(curl_buf); return -EINVAL; + } dbg("3\n"); dbg("url = %s\n", filename->original_url); + curl_set_cookie(curl, session->su_cookie); curl_easy_setopt(curl, CURLOPT_URL, filename->original_url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smugbatch-005/smugdown.c new/smugbatch-006/smugdown.c --- old/smugbatch-005/smugdown.c 2008-08-19 21:46:03.000000000 +0200 +++ new/smugbatch-006/smugdown.c 2011-07-19 20:16:59.000000000 +0200 @@ -156,7 +156,7 @@ list_for_each_entry(temp, &session->files_download, entry) { if (strcmp(temp->filename, filename->filename) == 0) { /* we found something to download */ - smug_download(filename); + smug_download(session, filename); } } } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org